JavaScript - Having Trouble With Unbelievably Simple Code!
So frustrating that lately I've been having trouble with the simplest of code, and this is about as simple as it gets. Matched it up with every similiar example I can find both in books and on the net, and it seems to be perfectly valid code, but when I run it, nothing. :S
Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script language="javascript" type="text/javascript"> function favouriteColour() { var index = document.getElementById("select1").options[document.getElementById("select1").selectedIndex].value; document.getElementById = "Your favourite colour is " + index; } </script> </head> <body> <select id="select1"> <option></option> <option id="black" onchange="favouriteColour()">Black</option> <option id="white" onchange="favouriteColour()">White</option> <div id="favcolour"></div> <option> </select> </body> </html> Thanks in advance. Similar TutorialsHi, thanks for taking the time to read this. I believe it is a very simple problem however I cannot get it to work, when I run it I enter info into the prompt and it seems to get stuck in a loop. Basically A prompt asks for user to enter a code (has to be either R or r or C or c) though when I enter one of those in it won't work. Code: <html> <head> <title>Water Usage</title> <script type="text/javascript"> // Setting our variables based on user input var code; var kl_c; var kl_r; var kl_c_cost; var kl_r_cost; code = prompt("Please Enter Code"); while ((code != "R") || (code != "C") || (code != "r") || (code != "c") || (code =="")) { alert("Please Enter C for Commercial or R for Residential"); window.location.reload(true); } if ((code == "C") || (code == "c")) { kl_c = prompt("Please Enter The Kilolitres Of Water Consumed"); kl_c_cost = (kl_c * 0.2) alert("The Total amount of water used for this Residential property is " + kl_c + " Kilolitres and the total cost is $" + kl_c_cost); } else if ((code == "R") || (code == "r")) { kl_r = prompt("Please Enter The Kilolitres Of Water Consumed"); kl_r_cost = (kl_r * 0.6) alert("The Total amount of water used for this Residential property is " + kl_r + " Kilolitres and the total cost is $" + kl_r_cost); } </script> </head> <body> </body> </html> Can some please help me. I'm really new at this and is having trouble with this simple example Code: <html> <head> <script type="text/javascript"> //Below i was trying to set up a var pam that includes some text //and the value of form field name pamcheck and then display that result of pam on the screen //using a check box with a value of 'pale ale malt' hoping that when the ckeck box is checked //and then user clicks submit the result would be displayed on the screen as // 'Your selected malt is Pale ale malt' function pamff1() { pam = ("<p>Your selected malt is <p>" + pamcheck); document.write(pam); } </script> </head> <body> <form onsubmit="pamff1();"> <input type="checkbox" name="pamcheck" value="Pale ale malt" > <input type="submit" value="Submit"> </form> </body> </html> Hello.. I'm in a Web Development basics class at my College. We are about two weeks in as we've blew through HTML and CSS. Anyway.. to the question. So for this class I need to make a website with terms and their definitions. The definitions have to be in Javascript and make them show up with an alert. The problem is, I can't figure out how to have unique functions that I can somewhat link with the button. Quote: <html> <head> <script type="text/javascript"> function show_alert() { alert('term definition ONE ') } </script> </head> <body> <input type="button" value="term definition ONE " onclick="show_alert()" /> <input type="button" value="term definition TWO " onclick="show_alert()" /> </body> </html> Making a new button would just link to the script that's in the <head> giving the same definition. It's almost like I need to give each function a variable that matches up with each button, since I have multiple terms.. I hope you get what I'm trying to say. I'm trying to create a type of virtual pagination that's simple, semantic, and SEO friendly. The concept is like this website: www.doner.com In the bottom right hand corner, if you select a city, different contact information appears. My theory is to assign a class name to the hyperlink, then have a DIV with a matching ID. For example... Code: <a href="#" class="michigan">Michigan</a> <a href="#" class="ohio">Ohio</a> <a href="#" class="illinois">Illinois</a> <div id="michigan"> Michigan container </div> <div id="ohio"> Ohio container </div> <div id="illinois"> Illinois container </div> The JavaScript I have written so far is... Code: var anchor = document.getElementsByTagName('a').className; // grab all hyperlinks and their classes var div = document.getElementsByTagName('div').getElementByID; // grab all divs and their IDs if (anchor = div) { // check to see if a hyperlink's class has a matching div ID div.style.display = "none"; if (anchor.onclick) { // if the hyperlink is clicked... div.style.display = "visible"; // make matching div ID visible } } Nothing works yet, and I don't know where to continue. The DIVs aren't even hidden upon loading. Can anyone help me? I'm trying to make an xhtml form that validates itself through a javascript function. I have the form up but for some reason I can't get it to validate. I'm not even sure if I linked things correctly. Here's what I have: the xhtml file <?xml version = ″1.0″ encoding = ″utf-8″ ?> <!DOCTYPE html PUBLIC ″-//W3C//DTD XHTML 1.0 Strict//EN″ http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <script src="gas24.js" type="text/javascript"></script> <h2> Registration Form </h2> <title> Javascript Form Validation Homework </title> </head> <body> <table border=""> <form name="validation_form" method="post" onsubmit="return validate()"> <tr> <td> <t>Name: <input type="text" name="YourName" size="10" maxlength="10"/> </td> </tr> </br> <tr> <td> E-mail Address: <input type="text" name="YourEmail" size="10" maxlength="24"/> </td> </tr> </br> <tr> <td> Password: <input type="password" name="YourPassword" size="10" maxlength="10"/> </td> </tr> </br> <tr> <td> Re-Type Password: <input type="password" name="passwordConfirmed" size="10" maxlength="10"/> </td> </tr> </br> <tr> <td> Your Gender: <input type="radio" name="MaleBox" Value="Male"> Male <input type="radio" name="FemaleBox" Value="Female"> Female </td> </tr> </br> <tr> <td> Comments: <input type="text" name="Comments" size="100" maxlength="500" value=""/> </td> </tr> <tr> <td> <input type="submit" value="Submit"/> </td> </tr> </form> </table> <p></p> </body> </html> The javascript file: I've tried two things. This: <SCRIPT LANGUAGE="JavaScript"> function validation() { var x=document.forms["validation_form"]["YourName"].value; if (x==null || x=="") { alert("First name must be filled out"); return false; } } And this: function validation() if ( document.validation_form.YourName.value == "" ) { alert( "Please type your name."); valid = false; } if ( document.validation_form.YourPassword.value =! "document.validation_form.Confirm.value" ) { alert ( "Please confirm your password." ); valid = false; } I would greatly appreciate it if somebody could tell me what I'm doing wrong. Hey guys im new (nebwbie) here lol but know about some basic coding i got my code from http://www.javascriptkit.com/script/...megamenu.shtml that is my source i followed all the steps and everything step by step but this is what shows up on my page what am i doing wrong? or is there something wrong with the code? i already uploaded this on my site too jkmegamenu.css jkmegamenu.js Hi all. I'm having some trouble w/ my radiobutton code and i dont know why. for instance if i select yes for the 1st radio button, and no for the 2nd, instead of doing what it should do for no, it gets rid of w/e it did for yes.. also, if i enter something into the 1st box, and select another radio button, it deletes w/e is in all boxes... Code: <html> <head><title>So you want to make a website?</title></head> <body> <script> var lvl=0; var cssbgc=0; var ischecked=0; var isgroup1=0; var isgroup2=0; function get_funcs(lvl){ if(lvl == "Easy"){ a='<hr>\n'; a+='<h1>Website Controls</h1>\n'; a+='Do you want to add a title to your website?<br>\n'; a+='Yes <input onclick="checkchecks()" type="radio" name="group1" value="Yes"> No<input onclick="checkchecks()" type="radio" name="group1" value="No"><br><br>\n'; a+='<div id="websitep">- Does not want website title</div><br>\n'; a+='Do you want to add a background image to your website?<br>\n'; a+='Yes <input onclick="checkchecks()" type="radio" name="group2" value="Yes1"> No<input onclick="checkchecks()" type="radio" name="group2" value="No1"><br><br>\n'; a+='<div id="websiteq">- Does not want website background</div><br>\n'; a+='Your Website scripts:<br><input name="websitescripts" type="text" size="30"> <a href="javascript:answerq(\'websitescripts\');">Help?</a><br>\n'; a+='<br>Your website content (this will appear inbetween <body></body>)<br>This can be done for you if you wish: <a href="javascript:answerq(\'webcontent\');">Help?</a><br><textarea rows="15" cols="45" id="websitecontent" name="websitecontent"></textarea><br>\n'; a+='<input type="button" value="Submit" name="sub1" id="sub1" onClick="checkconts(lvl)"><br>\n'; a+='<h1>Your Website</h1><hr>\n'; a+='<textarea rows="15" cols="45" id="websitelvl" name="websitelvl"></textarea>\n'; document.getElementById("websitecontrols").innerHTML = a; }else if(lvl == "Medium"){ a='<hr>\n'; a+='<h1>Website Controls</h1>\n'; a+='<table>\n'; a+='<tr><td>\n'; a+='Your Website background picture (if any):<br><input name="webback" type="file" size="30"> <a href="javascript:answerq(\'webback\');">Help?</a><br>\n'; a+='Your Website scripts:<br><input name="websitescripts" type="text" size="30"> <a href="javascript:answerq(\'websitescripts\');">Help?</a><br>\n'; a+='Do you want a website background color using css?<br><br>Yes<input onclick="check()" type="checkbox" value="Yes" id="group1" name="group1"> No<input onclick="check()" type="checkbox" value="No" id="group1" name="group1"><br>\n<div id="cssbc"></div>\n'; a+='<br>Your website content (this will appear inbetween <body></body>)<br>This can be done for you if you wish: <a href="javascript:answerq(\'webcontent\');">Help?</a><br><textarea rows="15" cols="45" id="websitecontent" name="websitecontent"></textarea><br>\n'; a+='<input type="button" value="Submit" name="sub1" id="sub1" onClick="checkconts(lvl)"><br>\n'; a+='</td></tr>\n'; a+='</table>\n'; a+='<h1>Your Website</h1><hr>\n'; a+='<textarea rows="15" cols="45" id="websitelvl" name="websitelvl"></textarea>\n'; document.getElementById("websitecontrols").innerHTML = a; } } function checkchecks(){ for (i=0; i<document.forms.radioform.group1.length; i++){ if(i == 0 && document.forms.radioform.group1[i].checked == true){ ischecked = 1; isgroup1 = 1; isgroup2 = 0; }else if(i == 1 && document.forms.radioform.group1[i].checked == true){ ischecked = 0; isgroup1 = 0; isgroup2 = 0; } } for (i=0; i<document.forms.radioform.group2.length; i++){ if(i == 0 && document.forms.radioform.group2[i].checked == true){ ischecked = 1; isgroup1 = 0; isgroup2 = 1; }else if(i == 1 && document.forms.radioform.group2[i].checked == true){ ischecked = 0; isgroup1 = 0; isgroup2 = 0; } } if(isgroup1 == 1){ alert('Make SURE this option is what you want. If you select another option after entering data, it will erase your data...'); a='Your Website Title:<br><input name="webtitle" type="text" size="30"> <a href="javascript:answerq(\'webtitle\');">Help?</a><br>\n'; document.getElementById("websitep").innerHTML = a; }else{ alert('Make SURE this option is what you want. If you select another option after entering data, it will erase your data...'); a='- Does not want website title<br>\n'; document.getElementById("websitep").innerHTML = a; } if(isgroup2 == 1){ alert('Make SURE this option is what you want. If you select another option after entering data, it will erase your data...'); b='Your Website background picture (if any):<br><input name="webback" type="file" size="30"> <a href="javascript:answerq(\'webback\');">Help?</a><br>\n'; document.getElementById("websiteq").innerHTML = b; }else{ alert('Make SURE this option is what you want. If you select another option after entering data, it will erase your data...'); a='- Does not want website background image<br>\n'; document.getElementById("websiteq").innerHTML = b; } alert('isgroup1:'+isgroup1+'|'+'isgroup2:'+isgroup2+''); } function check(){ for (i=0; i<document.forms.radioform.website.length; i++){ if(document.forms.radioform.website[i].checked == true){ alert('Make SURE this option is what you want. If you select another option after entering data, it will erase your data...'); if(i == 0 && document.forms.radioform.website[1].checked == true){ cssbgc = 0; document.forms.radioform.website[1].checked = false; }else if(i == 1 && document.forms.radioform.website[0].checked == true){ cssbgc = 1; document.forms.radioform.website[0].checked = false; } } } if(cssbgc == 0){ alert('ok then'); }else if(cssbgc == 1){ document.getElementById("cssbc").innerHTML = ""; } } function preview_website(){ if(document.forms.radioform.websitecontent.value != ""){ alert('Previewing your website...'); a='<center><h1>Website Preview<\/h1><\/center>\n<br><br>\n'; a+=document.forms.radioform.websitecontent.value+'\n'; document.write(a); } } function previewconts(){ if(document.forms.radioform.websitecontent.value != "" || document.forms.radioform.webtitle.value != "" || document.forms.radioform.webback.value != "" || document.forms.radioform.weblvl.value != ""){ preview_website(lvl); }else{ alert('Please enter something into the box before continuing...'); } } function checkconts(lvl){ if(document.forms.radioform.websitecontent == null || document.forms.radioform.websitecontent == null || document.forms.radioform.webtitle == null || document.forms.radioform.webback == null || document.forms.radioform.weblvl == null){ alert('Please select an option 1st...'); }else if(document.forms.radioform.websitecontent.value == null || document.forms.radioform.websitecontent.value == null || document.forms.radioform.webtitle.value == null || document.forms.radioform.webback.value == null || document.forms.radioform.weblvl.value == null){ alert('Please enter something into the box before continuing...'); }else{ a=document.forms.radioform.websitelvl.value = website(lvl); document.getElementById('websitecontent').innerHTML = a; } } function get_option(which){ if(which == "webtitle"){ return document.radioform.webtitle.value; }else if(which == "webback"){ return document.radioform.webback.value; }else if(which == "websitecontent"){ return document.radioform.websitecontent.value; }else if(which == "websitescripts"){ return document.radioform.websitescripts.value; } } function answerq(divname){ if(divname == "webtitle"){ alert('This is where you enter the name of your website that appears in the top left corner of your web browser.'); }else if(divname == "webback"){ alert('This is where you enter a background image link or a select a picture from your hard drive (IE: When selected you will see something like C:/mypics/pic.jpg appear in the box).'); }else if(divname == "webcontent"){ alert('this is where you enter what you want to appear on the page (this can be done for you if you wish).'); }else if(divname == "websitescripts"){ alert('This is where you enter any file locations to your script file(s).'); } } function website(lvl){ if(lvl == "Easy"){ a = "<html>\n"; a += "<head><title>"+get_option('webtitle')+"</title></head>\n"; if(document.forms.radioform.webback.value == ""){ a += "<body>\n"; }else{ a += "<body background=\""+get_option('webback')+"\">\n"; } if(document.forms.radioform.websitecontent.value != ""){ a += get_option('websitecontent')+"\n"; a += "</body>\n"; }else{ a += "</body>\n"; } a += "</html>\n"; } return a; } function callcontrols(lvl){ if(lvl == "Easy" || lvl == "Medium" || lvl=="Hard" || lvl == "Extreme"){ get_funcs(lvl); }else{ document.getElementById("websitecontrols").innerHTML = "NO!"; } } function getwebsite(lvl){ if(lvl == "Easy" || lvl == "Medium" || lvl == "Hard" || lvl == "Extreme"){ callcontrols(lvl); } } function get_radio_value() { for (var i=0; i < document.radioform.website.length; i++) { if (document.radioform.website[i].checked) { var rad_val = document.radioform.website[i].value; getwebsite(rad_val); } } lvl = rad_val; alert(lvl); } </script> <center> <h1>So you want to build a website?</h1><br> Easy - HTML Website<br> Medium - HTML / JavaScript / CSS Website<br> Hard - HTML / JavaScript / CSS / PHP Website<br> Extreme - HTML / Encrypted HTML / JavaScript / Encrypted JavaScript / CSS / PHP Website<br><br> You have four choices: <br> <form name="radioform"> Step 1:<br>Choose an option<br><br> Easy<input type="radio" onclick="get_radio_value()" name="website" value="Easy">Medium<input onclick="get_radio_value()" type="radio" name="website" value="Medium">Hard<input onclick="get_radio_value()" type="radio" name="website" value="Hard">Extreme<input onclick="get_radio_value()" type="radio" name="website" value="Extreme"><br><br> <div id="websitecontrols"></div> </form> </center> </body> </html> The functions you are looking at are checkchecks() and checkconts(). here's the functions: checkchecks(): Code: function checkchecks(){ for (i=0; i<document.forms.radioform.group1.length; i++){ if(i == 0 && document.forms.radioform.group1[i].checked == true){ ischecked = 1; isgroup1 = 1; isgroup2 = 0; }else if(i == 1 && document.forms.radioform.group1[i].checked == true){ ischecked = 0; isgroup1 = 0; isgroup2 = 0; } } for (i=0; i<document.forms.radioform.group2.length; i++){ if(i == 0 && document.forms.radioform.group2[i].checked == true){ ischecked = 1; isgroup1 = 0; isgroup2 = 1; }else if(i == 1 && document.forms.radioform.group2[i].checked == true){ ischecked = 0; isgroup1 = 0; isgroup2 = 0; } } if(isgroup1 == 1){ alert('Make SURE this option is what you want. If you select another option after entering data, it will erase your data...'); a='Your Website Title:<br><input name="webtitle" type="text" size="30"> <a href="javascript:answerq(\'webtitle\');">Help?</a><br>\n'; document.getElementById("websitep").innerHTML = a; }else{ alert('Make SURE this option is what you want. If you select another option after entering data, it will erase your data...'); a='- Does not want website title<br>\n'; document.getElementById("websitep").innerHTML = a; } if(isgroup2 == 1){ alert('Make SURE this option is what you want. If you select another option after entering data, it will erase your data...'); b='Your Website background picture (if any):<br><input name="webback" type="file" size="30"> <a href="javascript:answerq(\'webback\');">Help?</a><br>\n'; document.getElementById("websiteq").innerHTML = b; }else{ alert('Make SURE this option is what you want. If you select another option after entering data, it will erase your data...'); a='- Does not want website background image<br>\n'; document.getElementById("websiteq").innerHTML = b; } alert('isgroup1:'+isgroup1+'|'+'isgroup2:'+isgroup2+''); } checkconts(): Code: function checkconts(lvl){ if(document.forms.radioform.websitecontent == null || document.forms.radioform.websitecontent == null || document.forms.radioform.webtitle == null || document.forms.radioform.webback == null || document.forms.radioform.weblvl == null){ alert('Please select an option 1st...'); }else if(document.forms.radioform.websitecontent.value == null || document.forms.radioform.websitecontent.value == null || document.forms.radioform.webtitle.value == null || document.forms.radioform.webback.value == null || document.forms.radioform.weblvl.value == null){ alert('Please enter something into the box before continuing...'); }else{ a=document.forms.radioform.websitelvl.value = website(lvl); document.getElementById('websitecontent').innerHTML = a; } } The code I commeted out dosen't work I want to check if its null and if so alert them. { // PART 2: YOUR CODE STARTS AFTER THIS LINE correctAnswer = Math.floor((Math.random() * 100) + 1); // For testing purposes. alert("Testing purposes, correct answer is: " + correctAnswer); var number = 0; //// Calculations //if (isNaN(number) = true) { // alert("Thats not a number"); //} //document.write(number); while (number != correctAnswer) { number = prompt("Wrong Number, guess again."); number = Number(number); if (number < correctAnswer) { document.writeln("Small guess: " + number); } if (number > correctAnswer) { document.writeln("Large guess: " + number); } if (number == correctAnswer) { document.writeln("Correct guess: " + number); } } } I would like to compare my work to the work of others, can you please solve this and post your result? Declare an 8 x 8 matrix and an array of length 22. 1.- Populate the matrix. 2.- Copy the elements of the first row of the matrix, the anti-diagonal, and the last row of the matrix into the array, to form a Z shape. 3.- Sort the array. 4.- Assuming that the data in the arrays are grades, compute the average of the grades stored in the even locations of the array. 5.- Copy the array back into the matrix.(back into the Z) 6.- Print out the matrix values. index.html Code: <html> <head> <title>:: wtmp</title> </head> <body> <p>Welcome to my page</p> <script type="text/javascript" src="file.js"></script> </body> </html> file.js Code: function one(p1, p2) { var j_text=p1+" "+p2; return j_text; } function two() { var rslt=one("Hi", "there!"); } document.write(rslt); var mainscrpt=one("Hello", "world!"); window.alert(mainscrpt); I just started learning JavaScript. I'm sure it's something really simple but I cannot figure out what is missing from my code. No matter what year I enter into the text box, I keep getting "The year you entered, 2080393, is a leap year." It's not returning false...ever. Can someone please tell me what I'm doing wrong so I can stop pulling my hair out? Thanks! <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>Is It A Leap Year?</title> <script type="text/javascript"> /* <![CDATA[ */ function isLeapYear(year) { year = parseInt(year); var leapYear = true; var remainder = 0; if(isDivisibleBy(year, 4)) { leapYear = true; } if(isDivisibleBy(year, 100)) { leapYear = false; } if(isDivisibleBy(year, 400)) { leapYear = true; } if(leapYear) { window.alert("The year you entered, " + year + ", is a leap year."); } else { window.alert("The year you entered, " + year + ", is not a leap year."); } } function isDivisibleBy(year, divisor) { var remainder = 0; remainder = year%divisor; if(remainder == 0) { return true; } else { return false; } } /* ]]> */ </script> </head> <body> <form action="" id="GetLeapYear"> <p><strong>Is It a Leap Year?</strong></p> <p><strong>Enter a valid 4-digit year below to find out!</strong><br /></p> <p> <input type="text" name="year" size="20" style="color: black; border-style: solid; border-color: inherit; border-width: medium; background-color: Transparent" value="" /> <input type="button" value="Leap Year?" onclick="isLeapYear(document.getElementById('GetLeapYear').year.value);" /> </p> </form> </body> Simple random pic script that I found on the some other forum (I forget what it was) [CODE]var aryimages = new Array('images/pic/01.jpg', 'images/pic/37.jpg', 'images/pic/02.jpg', 'images/pic/family/08.jpg','images/pic/08.jpg', 'images/pic/food/03.jpg'); randompic.src = aryimages[Math.floor(Math.random() * aryimages.length)]; [CODE] code anchors to HTML markup [CODE]<img name="randompic" id="bg" />[CODE] it is working perfectly for Safari and Chrome. Nothing is showing for FF. Any suggestions appreciated. Here's the basic concept, its somewhat of a counter, and I think javascripts the way to go... Basically I'm looking to generate a running number... x + 11 = print the number The tricky part is, I need it to never stop, somewhat like a timer (example http://www.hashemian.com/tools/javascript-countdown.htm) but not a timer... Think the tally mark on McDonald's 99 billion served.. Any suggestions or ideas? Hi... i have this code: <script type='text/javascript'> cookie_name = GetCookie("href_location"); if(cookie_name){ alert("Cookie found, redirecting to stored cookie."); document.location.href=cookie_name; } </script> I will like to create a iframe using the info from the "cookie_name" value <iframe name="FRAME1" src="cookie_name" width="350" height="320" frameborder="0" scrolling="auto"></iframe> I have a script that set a cookie with the value of a chosed website, what i need now is to create an iframe with that value. Any help will be apriciated. Sorry for my poor enlish can some please tell me what this line does... Code: <div onClick="getElementById('tInfo').onclick();"> Hi everyone, I've been coding Perl for quite some time, but I'm new to Javascript and can't quite figure this out. I want to call a Javascript function that is sent to the browser via a perl script. When I hard code the string "Fargo" into the code it works just fine, when I pass the word Fargo via a variable the script will not call the function what so ever. Is it possible to call a javascript function via a Perl script with Perl providing all the necessary data? Here is my code: #!/usr/local/bin/perl use CGI qw(:all); use CGI::Carp qw(fatalsToBrowser); use Cwd; print header; print "top<br><br>"; $data = "fargo"; print <<html; <html><head></head>my heading is here<br><body></body> <script type="text/javascript"> function testz(inbound) { document.write("im in ", inbound); } //the script will only work if I uncomment the line below and comment out two lines below //var data1="fargo"; var data1 = $data; testz(data1); </script> </html> html Thanks to everyone in advance for your help. Basically, I have a Simon Says game with very simple functions but I added an image map with buttons that I now want to use, rather than a table with images as buttons. The problem is, now I can't get the game to work with the image map. Can anyone help me?
Hello, What I need is a simple service area, zip code validation form that redirects to a certain URL when a valid zip code is submitted and a different URL when an invalid zip code is submitted. I found a form script example that works well with only a single zip code. My problem is I can't figure out how to modify it so that multiple zip codes are valid. Here is the head part. 60016 is one of about 50 valid zip codes I need the form to accept as valid - [code] <script> var correctCode = "60016"; function validateCode() { var code = document.getElementById("codeTextBox").value; if (code == correctCode) { window.location.href = "/ggc/test1"; } else { window.location.href = "/ggc/test2"; } } </script> [code] Here is the body part - [code] Please enter your zip code: <input type="text" name="codeTextBox" id="codeTextBox" /> <input type="submit" name="Submit" value="Submit" onclick="validateCode()" /> [code] |