Search the Community

Showing results for tags 'if'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Calendars

  • Community Calendar

Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 19 results

  1. [SOLVED]
  2. The comment basically has my issue, but I'm basically trying to fix my second var prompt so it will actually run and I can't figure it out. If anyone can help I would greatly appreciate it. Line comment: var one above this comment isn't working, how do I fix it? I also need it to continue to the next else if statement once something is entered. I'm thinking of making it so that if it changes var input to 2 once it's entered then 3, will that work? <!DOCTYPE html> <html> <head> <title>Project 1 – Michael Fiorello</title> <script> do{ var input = prompt ("Please enter 1, 2, 3, or exit.");{ if (input == "1") {for var one = prompt ("Please enter a string"); //var one above this comment isn't working, how do I fix it? I also need it to continue to the next else if statement once something is entered. I'm thinking of making it so that if it changes var input to 2 once it's entered then 3, will that work? if (one != null) else console.warn("You need to enter something") }in(one !="") //need the above "in" to cause it to loop this section until something is entered for var one else if (input == "2") { alert ("COOL!") } else if (input == "3") { alert ("AWESOME!") } else if (input.toLowerCase() == "exit") { alert ("Okay") } else { alert ("Nope") console.warn("You need to enter something"); } } }while(input != "exit"); </script> </head> <body> </body> </html>
  3. So, I have a code that asks a question, and if the answer in correct, it says correct in the div. If incorrect, it says incorrect. For some reason it always says incorrect even if my answer is correct. Please help, is there anything wrong with this code? //*If players 1 turn if (player == "1"){ //*Asks question var trivia = prompt(questions_obj.question); //*If answer is corerct do stuff if (trivia === questions_obj.answer){ document.getElementById('correctincorrect').innerHTML = "Correct"; $('#character1').animate({left: "+=75px"}, 500, function(){ //*If player gets to finish they win if (player1total == "8"){ var winner1 = alert("Player 1 is the winner!"); $('#character1').remove(); $('#character2').remove(); $('#character3').remove(); $('#player1score').remove(); $('#player2score').remove(); $('#player3score').remove(); $('#player1header').remove(); $('#player2header').remove(); $('#player3header').remove(); $('#player1board').remove(); $('#player2board').remove(); $('#player3board').remove(); } }); //*Adds up players score player1total = player1total + 1; document.getElementById("player1score").innerHTML = player1total; } if (trivia === questions_obj.answer2){ document.getElementById('correctincorrect').innerHTML = "Correct"; $('#character1').animate({left: "+=75px"}, 500, function(){ //*If player gets to finish they win if (player1total == "8"){ document.getElementById('correctincorrect').innerHTML = "Player 1 is the winner!"; $('#character1').remove(); $('#character2').remove(); $('#character3').remove(); $('#player1score').remove(); $('#player2score').remove(); $('#player3score').remove(); $('#player1header').remove(); $('#player2header').remove(); $('#player3header').remove(); $('#player1board').remove(); $('#player2board').remove(); $('#player3board').remove(); } }); //*Adds up players score player1total = player1total + 1; document.getElementById("player1score").innerHTML = player1total; } if (trivia != questions_obj.answer || trivia != questions_obj.answer2){ document.getElementById('correctincorrect').innerHTML = "Incorrect"; }}
  4. Can anyone tell me why this Javascript isn't working? (The following is the PHP code:) if ($quantity>$inventory) { echo '<script language="javascript"> var i = confirm("There are '; echo number_format($inventory); echo ' copies in inventory in '; echo $warehouse_name; echo '.nnThis order is for '; echo number_format($quantity); echo ' copies.nnThat is '; echo number_format($difference); echo ' more than are available.nnClick OK to create a backorder for this itemnor Cancel to abort."); if (!i) window.close();'; echo '</script>'; } The idea is simple: A confirm box opens with a message. If the user clicks OK, the PHP code continues. If the user clicks Cancel, the window should close without executing any more PHP code. Right now, it doesn't matter which button you click: the PHP code just continues regardless. How can I fix this?
  5. Hello i try make it like: <html><head> <script type="text/javascript"> function Code() { A=["T1","T2","T3",4,2,1]; var B1=A;var B2=A;var B3=A; if (A[0]=="T2") {B1[3]=5;} if (A[1]=="T2") {B2[3]=5;} if (A[2]=="T2") {B3[3]=5;} document.getElementById('W1').innerHTML="B1:"+B1[3] document.getElementById('W2').innerHTML="B2:"+B2[3]; document.getElementById('W3').innerHTML="B3:"+B3[3]; } </script></head><body> <input type="button" value="Code it!" onClick="Code()"><br><br><br> <div id="W1"></div> <div id="W2"></div> <div id="W3"></div> </body> when i press button then i got 5 on all B1, B2 and B3. but it should be only B2 have 5 while other got 4. Why it going wrong?
  6. Hello, I am still rather new to JavaScript. I am working on making a study tool for school. Below I have a sample of my code. I would like for a case to included in the array WordList only if a condition is true. I have check-boxes for each case. What I have currently is a poor workaround where if for example case 1's box is not checked it will shuffle again and then run the function again. Instead, I would like to make it so that if case 1's box is not checked it won't be included in the array at all, if that's possible. I'm sorry I can't explain this very well. Thanks in advance for any input. Array.prototype.randomize = function(){ var i = this.length, j, temp; while ( --i ) { j = Math.floor( Math.random() * (i - 1) ); temp = this[i]; this[i] = this[j]; this[j] = temp; }}var WordList = [0,1];WordList.randomize();function Word() {var WordL = WordList [0];switch (WordL) { case 0: if(document.getElementById('micro').checked) { WordL = MicroList.randomize(); Micro();} else {WordList.randomize(); Word();} break; case 1: if(document.getElementById('immuno').checked) { WordL = ImmunoList.randomize(); Immuno();} else {WordList.randomize(); Word();}}}
  7. I am fairly new to PHP and I was tasked with migrading an app that runs on php 4+ enviroment into a 5.4 enviroment and I am getting warnings becasue its very old code, but I also would lie to know if there is a better way of writing the fallowing script of php code. It checks weather a member has attended a course and if so it charges a price if not its a different price and so on. Any help would be very appriciated. <?phpif ($semattend == 'MEMBER-ATTENDED') {$total = "<tr> <td height="30" align="right"><p><font color="#FF9900">*</font><font size="2">Total: </font></p></td> <td height="30" colspan="3" align="left"><font size="2"><input type="hidden" id = "amount" value="1299" name="amount" size="28">$1,299</font></td> </tr> <tr> <td colspan="3" align="left"><p>Search results indicate that you belong to a member instituion and have completed the Essentials of SEM course</p></td> </tr> <input type="hidden" id = "semstatus" value="MEMBER-ATTENDED" name=semstatus"> <input type="hidden" id = "attended" value="Attended Course" name="attended"> <input type="hidden" id = "member" value="Member" name="member">";} elseif ($semattend == 'MEMBER-NOTATTENDED') {$total = "<tr> <td height="30" align="right"><p><font color="#FF9900">*</font><font size="2">Total: </font></p></td> <td height="30" colspan="3" align="left"><font size="2"><input type="hidden" id = "amount" value="1799" name="amount" size="28">$1,799</font></td> </tr> <tr> <td colspan="3" align="left"><p>Search results indicate that you belong to a member instituion and have not completed the Essentials of SEM course</p></td> </tr> <input type="hidden" id = "semstatus" value="MEMBER-NOTATTENDED" name=semstatus"> <input type="hidden" id = "attended" value="Not Attended Course" name="attended"> <input type="hidden" id = "member" value="Member" name="member">"; } elseif ($semattend == 'NONMEMBER-ATTENDED') {$total = "<tr> <td height="30" align="right"><p><font color="#FF9900">*</font><font size="2">Total: </font></p></td> <td height="30" colspan="3" align="left"><font size="2"><input type="hidden" id = "amount" value="1599" name="amount" size="28">$1,599</font></td> </tr> <tr> <td colspan="3" align="left"><p>Search results indicate that you do not belong to a member instituion and have completed the Essentials of SEM course</p></td> </tr> <input type="hidden" id = "semstatus" value="NONMEMBER-ATTENDED" name=semstatus"> <input type="hidden" id = "attended" value="Attended Course" name="attended"> <input type="hidden" id = "member" value="Non Member" name="member">"; } elseif ($semattend == 'NONMEMBER-NOTATTENDED') {$total = "<tr> <td height="30" align="right"><p><font color="#FF9900">*</font><font size="2">Total: </font></p></td> <td height="30" colspan="3" align="left"><font size="2"><input type="hidden" id = "amount" value="2099" name="amount" size="28">$2,099</font></td> </tr> <tr> <td colspan="3" align="left"><p>Search results indicate that you do not belong to a member instituion and have not completed the Essentials of SEM course</p></td> </tr> <input type="hidden" id = "semstatus" value="NONMEMBER-NOTATTENDED" name=semstatus"> <input type="hidden" id = "attended" value="Not Attended Course" name="attended"> <input type="hidden" id = "member" value="Non Member" name="member">"; }echo $total;?>
  8. i was trying to apply condition to some query to execute.. if ($col != 'name' or 'item') {// query would execute here} but it is not doing as expected. i want both conditions (or may be more) to execute the query but it is working only in first condition (i.e. $col != 'name') but not working for second (i.e. $col != 'item').. please guide me through
  9. hi everyone, I'm having trouble with a PHP if statement. I'm getting a value back from a database. the values stored in the DB aren't exactly what I want to display so im going to do a inline conversion on them. I want to say for example: if the region = 'central' then display 'central Scotland'. ive added my conversion but the value that is stored in the DB is showing rather than the converted value. can anyone spot what is wrong? UPDATE: OK, so it works for all of these apart from the "North & Islands" one. all othere convert, but this one doesn't. it doesn't change to "North, Highlands & Islands" it just stays as "North & Islands". the others change. the code is below: <h3><strong>Region:</strong> <?php if($db_oregion=="Central"){echo("Central Scotland");} elseif($db_oregion=="East"){echo("East Anglia");} elseif($db_oregion=="Mid"){echo("Mid & West Wales");} elseif($db_oregion=="North"){echo("North Wales");} elseif($db_oregion=="North & Islands"){echo("North, Highlands & Islands");} elseif($db_oregion=="South"){echo("South Wales");} else{echo($db_oregion);} ?> </h3>
  10. i'm trying to get make query relating to the date selection. and if no date is selected, i want to make default query without date selection. for this i tried this ---- // above this there is a form with two input fields for from date and to date selection with a submit buttom. action is $_SERVER['PHP_SELF']if (!isset($_POST['sort'])) { // 'sort' is the submit button name$query = "SELECT * FROM tran WHERE ssn!=0 ORDER BY date";} else { $fdate == $_POST['fdate']; // from date $tdate == $_POST['tdate']; // to date$query = "SELECT * FROM tran WHERE ssn!=0 AND date BETWEEN '$fdate' AND '$tdate' ORDER BY date";} but this is not working... any suggestion!!!?????
  11. I have this issue with a function where I want to execute 4 different actions inside an if statement. My code looks like this: function deltagare(){var myTextField1 = document.getElementById('namn');var myTextField2 = document.getElementById('epost'); if(myTextField1.value != "" && myTextField2.value != "")document.getElementById("deltagare-list").value+=myTextField1.value+" "+"("+myTextField2.value+")"+"\n",document.getElementById("deltagare-emaillist").value+=myTextField2.value+",",document.getElementById('namn').value="",document.getElementById('epost').value=""; elsealert("Skriv in både namn och epost!"); } In this way only the first action gets executed. How can I add the other ones properly?
  12. Hi I have simply select and works great: select 'CARAT Issue Open' issue_comment, i.issue_id, i.issue_status, i.issue_title, i.ISSUE_summary ,i.issue_description, i.severity,gcrs.Area_name, gcrs.sector_name,substr(gcrs.stream_name,1,case when instr(gcrs.stream_name,' (')=0 then 100 else instr(gcrs.stream_name,' (')-1 end) ISSUE_DIVISION,case when gcrs.STREAM_NAME like 'NON-GT%' THEN 'NON-GT' ELSE gcrs.STREAM_NAME END as ISSUE_DIVISION_2from table(f_carat_issues_as_of('31/MAR/2013')) iinner join v_gcrs_with_stream gcrs on i.segment_id = gcrs.segment_idwhere UPPER(ISSUE_STATUS) like '%OPEN%' Now I want to callte two columns: ISSUE_DIVISION and ISSUE_DIVISION_2 if they are equal in new columns should be value 1 if are not equal should be 0, how can I do it ?
  13. Hello, I have a problem involving Phpmailer and a While loop. Actually I have always had problems to sending emails this way. Now for instance I can send e-mails trough an IF (instead of While) and the following script works fine. But as soon as I change it into While it doesn't. Even the last part of the script (UPDATE) doesn't work (it worked upon IF). I am trying with just two e-mails to be sent and only the first one is sent.I would be so happy to solve this issue. While loop is really important when it comes to sending e-mails. This is my script: ...include('conexioninclude.php');mysql_set_charset('utf8');$registros=mysql_query("SELECT mail, name, password, codigo FROM alert WHERE status='on' AND language1='$language2' AND language2='$language1' AND way LIKE '%$way%' ORDER BY codigo",$conexion)ordie("Problems at selectt:".mysql_error());require("class.phpmailer.php");$mail = new PHPMailer();while($reg=mysql_fetch_array($registros)){$mailu=$reg['mail'];$namee=$reg['name'];$password=$reg['password'];$codigo=$reg['codigo'];$mail->IsSMTP();$mail->Port = 465;$mail->SMTPSecure = "ssl"; $mail->Host = "smtp.gmail.com"; $mail->SMTPAuth = true;$mail->Username = "xxxxx";$mail->Password = "xxxxxx"; // SMTP password$webmaster_email = "xxxxxx"; //Reply to this email ID$email="xxxxx"; // Recipients email ID$name="Admin"; // Recipient's name$mail->From = "xxxxxx";$mail->FromName = "Sharinglanguage.com";$mail->AddAddress($mailu,$namee);$mail->AddReplyTo(xxxxxx,"Webmaster");$mail->WordWrap = 50; // set word wrap$mail->SetLanguage("en","/php/language/");$mail->AddAttachment("/var/tmp/file.tar.gz");$mail->AddAttachment("/tmp/image.jpg", "phone.jpg");$mail->AddAttachment("image.jpg", "phone.jpg"); $mail->IsHTML(true); // send as HTML$mail->Subject = "xxxxxxxxx";$foto= "imagess/bonito.jpg";$mensaje='<font-color="#559999"><img src="'. $foto .'" width="600"><br /><br />Hello '.$namee.',<br /><br />xxxxxxxxxxxxxxxx .<br /><br />Sincerely yours</font>'; $mail->MsgHTML($mensaje);if(!$mail->Send()){print<<<HEREmessage wasn't sent;HERE;}else{$registros2=mysql_query("SELECT yep FROM vamos WHERE password='$password'",$conexion)ordie("Problems at selectt:".mysql_error());if($reg=mysql_fetch_array($registros)){$yep=$reg['yep']; // it's an Int type field (numbers)$saw=$yep+1;$registros3=mysql_query("UPDATE vamosSET yep='$saw'WHERE password='$password'",$conexion)ordie("Proble8uhims with selectttt:".mysql_error());}print<<<HEREsuccess!;HERE;}... Thank you very much in advance for any help. Regards
  14. Please kindly go tohttp://lifelearning.xtreemhost.com/lib.htmlA testing page. Just check the checkbox "Lib1" and do not enter anything in the input boxI have checked if sFound1 is null in the if condition (already commented in the codes,but the table (at the bottom) still returns the null value. Can anyone help me a bit here?Many thanks in advance.
  15. var b = true;window.onload = function(){(b==true) ? function(){ var c = "Hello!"; func(c); } : null ;}function func(c){document.write("The word is " + c);} It seems that the function cannot be loaded in this tenary operator.Why's that?
  16. Hello w3 again... what im trying to is that im making a request page. and in this request page, then instead of taking the whole imdb URL out from the DB.then how can i do with a if so there is going to stand "Yes" if filled and "NO" if not?... i have tried this: echo "<td>".if(mysql_num_rows($r_row['r_imdb_link']) > 0){echo "Yes";}else {echo "No";}."</td>"; but got a error... but i also tried with a fetch_assoc before the num_rows... and that was the same... error was this: Parse error: syntax error, unexpected T_IF in C:\xampp\htdocs\ss_tracker_2011\request.php on line 101 and with num rows this: Parse error: syntax error, unexpected T_IF in C:\xampp\htdocs\ss_tracker_2011\request.php on line 101 The very same...ideas?... (Pictures added what i ment if no ideas got from my own words...)
  17. Hello folks.Here is my problem.I have a bunch of hidden id's with values but I need to check to see if those values are right before I submit my form. I tried an if statement but it is just not working. I am trying something like Function checkquad(){if(r1.value="");if(r2.value="");{alert("r1 and r2 not filled out right");}} What I am trying to say with my if statements is that if the value r1 and r2 (from a from I named tourney) do not have a value set yet then send out the alert and dont submit the form... Not working...
  18. Hey guys!I was wondering if someone would be kind enough to help me out. I am not really a programmer or savvy in that type of nature. I know HTML / CSS but really my experience is in the design field. I am using software called osDate.osDate allows you to give your site a title and meta tags from the admin interface, BUT... osDate doesn't support changing your title/meta tags for specific pages, this is a huge problem for me and the SEO of my site! Here's what I need and I'm hoping someone can help me out with. I want to know if someone could write me a quick tutorial or possibly show me how the code would work to do the following: IF we are on page 'page.php' then use 'THIS' as my title site. As an added bonus, I wonder would hard it would be to fetch 'THIS' from.. let's say a text file? or php file where i can define all the titles etc that get pulled into my title/meta tags? (the same theory would be applied in the meta tags/description) if anyone could gimme a hard, I'd greatly appreciate it! Thanks!
  19. Hello, I am currently trying to make a form that when edited will updated what the table on the front page shows.The way it will work is by updating a MySQL database. In my code for the form I want it to grab the "flavor" that is currently showing, and place it as the " selected" in the option field, so who ever edits it can see right there which flavors are already showing. Please note there are TWO different tables in the DB, one table holds ALL of the flavors, the other holds only 8 flavors that will show on the front page: Code: <table><tr><td><h1>Change Flavors:</h1><br /></td></tr> <?php while($count <= 8){ echo "<tr><td><form>"; echo "Flavor #{$count}: "; echo "<select name=\"in_store\">"; $flavor_set = get_flavors(); $in_store_set = get_flavors_in_store(); $in_store = mysql_fetch_array($in_store_set); while($flavors = mysql_fetch_array($flavor_set)){ echo "<option value=\"{$flavors['flavor_name']}\""; if($flavors['flavor_name'] == $in_store['flavor']){ echo " selected"; } echo ">{$flavors['flavor_name']}</option>"; } echo "</select>"; echo "<input type=\"submit\" value=\"Edit Flavor #{$count}\""; $count++; echo "</form><br /><br />"; echo "<img src=\"images/line.png\" width='500px' height='2px' /><br /><br />"; echo "</td></tr>"; }?></table> The table that holds all the flavors is $flavor_set, the home page table is $in_store_setget_flavors() and get_flavors_in_store() and two functions that I have set to get the info out of the DB. Thanks!