JavaScript - Js Code To Solve This Exam
Hey all ,
the attached file contains the source code of a MCQ exam , i need a JS code that solves that MCQ exam . I really need it and as soon as possible . thank you so much for your time Best Regards, MIG()ZZZZ Similar Tutorialsi want to restrict refresh option for online examination can any one give me solution as early as possible .....please I have written below script for timer when i refresh the page timer is reset again. <script type="text/javascript"> var settimmer = 0; $(function(){ window.setInterval(function() { var timeCounter = $("b[id=show-time]").html(); var updateTime = eval(timeCounter)- eval(1); $("b[id=show-time]").html(updateTime); if(updateTime == 0){ $("div[id=my-timer]").html("").html("Page redirecting........"); window.location = ("welcome.php"); } }, 1000); }); </script> // Body Part <div id="my-timer"> Page Will Redirect with in <b id="show-time">1800</b> seconds </div> Thank You ...! This is very basic yet i can find the answer. How do you stop a countdown function?
I must be misunderstanding a fundamental aspect of javascript because I have been sitting here scratching my head for an hour trying to figure out why my code produces a nAn for the gpa calculation. I intended the calcutator to erase any entries that are not standard grades, and prompt the user to fill in blanks if there are any. I apologize if the code is too long. I think there is a probably a way to cut it down, so if someone could tell me how that would also be extremely helpful. P.S. the calculator is supposed to convert the letter grade to the gpa score (A-->4.0) so if someone could explain how it would be done in an array instead that would help. I tried to do it, but I couldn't get that to work. This way is functional albeit long. My main issue is the calculator's inability to calculate! Thank you for any responses. I cannot attach anything so I will include a pastebin link instead: http://pastebin.com/DfyR46p2 I need help calculating the average for a Practical Exam 1) the teacher asked us to create a for loop and prompt the user to enter 10 numerical grade. (which I did) 2) She wants us to find the average of the user's 10 entry, and give them their final grades (ex: user enters 80, 90, 70, 90 etc.., the counter will stop prompting for entry after the 10th entry) I need to display, your final grade for the class 85, you've got a B) I need help figuring out the average formula! Please, i need to e-mail the teacher my practical by 10 PM (eastern time). Thank you, victory1 1)HOW TO SET THE DECIMAL TO 1 OR 2 POINT ONLY 2)HOW TO MAKE SURE ALL THE QUESTIONS ANSWERED B4 PERCENTAGE IS CALCULATED why it is not working in firefox? HERE IS THE EDITED CODE. var numOfGroups = 12; function calc() { var score = 0; for (var j=1; j<=numOfGroups; j++) { var f = document["myform"]["ques"+j]; for (var i=0; i<f.length; i++) { if (f[i].checked) { score += Number(f[i].value /72 *100); } } } //confused here..do i need to create new function somenthing like this function showScore() { if(answered != answers.length) { alert("You have not answered all of the questions yet!"); return false; OR } //if numOfGroups != 12 { alert("You have not answered all of the questions yet!"); } else{ alert ("Your Score is " + score); return false; } </script> hey guys, I'm not the quickest running in the race, but I'm slowly learning JavaScript. I'm attempting to use the jQuery iviewer to control the viewing of images. I'm essentially making my own slideshow. In any event, I'm trying to tag a map along with the image. The only way I know of doing this is with standard markup doing usemap="#map_name". so here's my JavaScript code, and the HTML to follow. Code: var $ = jQuery; $(document).ready(function(){ $("#viewer").iviewer( { src: "images/page11.jpg", update_on_resize: false, initCallback: function () { var object = this; $("#in").click(function(){ object.zoom_by(1);}); $("#out").click(function(){ object.zoom_by(-1);}); $("#fit").click(function(){ object.fit();}); $("#orig").click(function(){ object.set_zoom(100); }); $("#update").click(function(){ object.update_container_info();}); }, onMouseMove: function(object, coords) { }, onStartDrag: function(object, coords) { return false; }, onDrag: function(object, coords) { } }); $("#viewer2").iviewer( { src: "images/page11.jpg", update_on_resize:false, initCallBack: function () { document.images[0].useMap = "#map1"; } }); }); And the 'scaler' Code: function scalecoordimages(elImage, amount){ var elMap = getMap(elImage) elImage.width *= amount; elImage.height *= amount; if (null != elMap){ for (var intLoop = 0; intLoop < elMap.areas.length; intLoop++) { var elArea = elMap.areas[intLoop]; var coords = elArea.coords.split(","); var scaledCoords = ""; for (coords in coords) { scaledCoords += (coords[coord] * amount) + ","; } elArea.coords = scaledCoords; } } } and now the HTML where this is all delivered. Code: <div class="wrapper"> <div id="viewer2" class="viewer" style="margin: 50px auto;"></div> </div> the 'wrapper' is because in Safari the overflow doesn't hold properly and breaks. the Map is just rectangles...it's below > Code: <map name="map1" id="map1"> <area class="hotspot" shape="rect" coords="105, 1110, 371, 1125" href="" onMouseOver="tooltip.show('<ul>Northeast States:<br /><li>Connecticut</li><li>Maine</li> <li>Massachusetts</li><li>New Hampshire</li><li>Rhode Island</li><li>Vermont</li><li>New Jersey</li><li>New York</li><li>Pennsylvania</li></ul>');" onMouseOut="tooltip.hide();" > <area class="hotspot" shape="rect" coords="105, 1135, 371, 1150" href="" onMouseOver="tooltip.show('<ul>Midwest States:<br /><li>Indiana</li><li>Illinois</li><li>Michigan</li><li>Ohio</li><li>Wisconsin</li><li>Iowa</li><li>Kansas</li><li>Minnesota</li><li>Missouri</li><li>Nebraska</li><li>North Dakota</li><li>South Dakota</li></ul>');" onMouseOut="tooltip.hide();"></area> <area class="hotspot" shape="rect" coords="105, 1160, 371, 1175" href="" onMouseOver="tooltip.show('<ul>Southern States:<br /><li>Delaware</li><li>Florida</li><li>Georgia</li><li>Maryland</li><li>North Carolina</li><li>South Carolina</li><li>Virginia</li><li>West Virginia</li><li>Alabama</li><li>Kentucky</li><li>Mississippi</li><li>Tennessee</li><li>Arkansas</li><li>Louisiana</li><li>Oklahoma</li><li>Texas</li></ul>');" onMouseOut="tooltip.hide();"></area> <area class="hotspot" shape="rect" coords="105, 1185, 371, 1200" href="" onMouseOver="tooltip.show('<ul>Western States:<br /><li>Arizona</li><li>Colorado</li><li>Idaho</li><li>New Mexico</li><li>Montana</li><li>Utah</li><li>Nevada</li><li>Wyoming</li><li>Alaska</li><li>Californai</li><li>Hawaii</li><li>Oregon</li><li>Washington</li></ul>')" onMouseOut="tooltip.hide();"></area> </map> Any help is appreciated. Thank you. The following code is needed for the prettyphoto javascript popup. It works fine in Firefox and Safari, but not in any version of IE. Can anyone suggest why? <script> jQuery.noConflict(); $(document).ready(function(){ jQuery("a[rel^='prettyPhoto']").prettyPhoto(); }); </script> Hi; Please can somebody help me make this code work for me. i want it to work in such a way that when someone select the ages in the combo box,it will direct the person to another page. Here is it <html> <body> <script type="text/javascript"> page = document.frmOne.cmbAge.value switch (page) { case "1": document.URL = "page1.html" break case "2": document.URL = "page2.html" break case "3": document.URL = "page3.html" break case "4": document.URL = "page4.html" break default: alert("An error occurred, so we are staying here") } </script> </body> <form name="frmOne"> <select name = "cmbAge"> <option value = 1>5 to 16</option> <option value = 2>17 to 30</option> <option value = 3>31 to 45</option> <option value = 4>46+</option> </select> </form> </body> </html> Please help me solve this.. Thanks you. Clement Osei. Please Check the webpage to see what I am trying to do. I am told It cant be done in HTML. That I will have to use Java Script. Can someone Please help me out here. Go to: http://www.capthelm.net If You can assist me please use the email link on my site. Thanks. The Captain I have a form and the Js validation wont work on it. Here is the html PHP Code: <form name="frm" action="index.php" method="POST" onsubmit="return validateForm();"> <table width="100%" border="0" cellspacing="2" cellpadding="3" class="mainForm"> <tr> <td class="normalText" align="left" style="padding:0px 0px 0px 33px"> <table border="0" cellspacing="3" cellpadding="2"> <tr> <td class="normalHeading" colspan="2" style="padding-bottom:6px"> <div id="error_msg" class="txtErrorMsg" align="center"></div> <!-- <?php echo "<p id=\"error_msg\">".$message."</p>"?> --> </td> </tr> <tr > <td class="normalText" width="30%">First Name</td> <td><input type="text" name="firstName" id="firstName" class="input1" style="width:195px" maxlength="10"/></td> </tr> <tr> <td class="normalText">Last Name</td> <td><input type="text" name="lastName" id="lastName" class="input1" style="width:195px" maxlength="10"/></td> </tr> <tr> <td class="normalText">Mobile</td> <td><input type="text" name="mobile" id="mobile" class="input1" style="width:195px" maxlength="10" onkeypress="return fnIsIntNumber(event,this);"/></td> </tr> <tr> <td class="normalText">Email</td> <td><input type="text" name="email" id="email" class="input1" style="width:195px" onblur="IsEmail(this.vlaue)"/></td> </tr> <tr> <td class="normalText">Comments</td> <td> <textarea name="comments" id="comment" cols="22" rows="3" ></textarea> </td> </tr> <tr> <td class="normalText"> </td> <td valign="middle"><input class="send" type="image" value='submit' src="images/submit.gif" name="submit" /></td> </tr> </table> </td> </tr> </table> </form> and here is the JS PHP Code: var $j = jQuery.noConflict(); function isValidEmail(str) { return (str.indexOf(".") > 2) && (str.indexOf("@") > 0); } function validateForm(){ var firstName; var lastName; var email; var mobile; var comment; var error; firstName = $j('#firstName').val(); lastName = $j('#lastName').val(); email = $j('#email').val(); mobile = $j('#mobile').val(); comment = $j('#comment').val(); if(firstName=='' || firstName.length < 3){ error = 'Please Enter Your First Name'; $j('#errormsg').html('<p class="errors">'+ error +'</p>'); return false; } if(lastName=='' || lastName.length < 3){ error = 'Please Enter Your Second Name'; $j('#errormsg').html('<p class="errors">'+ error +'</p>'); return false; } if(email=='' || !isValidEmail(email)){ error = 'Please Enter Your Correct Email'; $j('#errormsg').html('<p class="errors">'+ error +'</p>'); return false; } //mob //$jmob_pattern = '^\d{10}$j'; if(mobile.length != 10 || isNaN(mobile)){ error = 'Please Enter Your Correct Mobile Number'; $j('#errormsg').html('<p class="errors">'+ error +'</p>'); return false; } if(comment.length < 10){ error = 'Please Enter A Comment More Than 10 Characters'; $j('#errormsg').html('<p class="errors">'+ error +'</p>'); return false; } return true; } Can anybody tell me what the problem is Code: <!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> <title> Jackhammer </title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript"> /* <![CDATA[ */ var jackhammers = new Array(11); var curJackhammer = 0; var direction; var begin; jackhammers[0] = "jackhammer0.gif"; jackhammers[1] = "jackhammer1.gif"; jackhammers[2] = "jackhammer2.gif"; jackhammers[3] = "jackhammer3.gif"; jackhammers[4] = "jackhammer4.gif"; jackhammers[5] = "jackhammer5.gif"; jackhammers[6] = "jackhammer6.gif"; jackhammers[7] = "jackhammer7.gif"; jackhammers[8] = "jackhammer8.gif"; jackhammers[9] = "jackhammer9.gif"; jackhammers[10] = "jackhammer10.gif"; function bounce() { if(curJackhammer == 10) curJackhammer = 0; else ++curJackhammer; /* Firefox does not register an error with the line of code below, but other browsers do . . . It looks like it is a typo left over from the slightly more advanced technique in 10-4 where jackhammers.src is defined. Also, were you to comment out the final line in this function you would see the animation does not work. In browsers other than Firefox which apparently just ignores this code and no animation occurs, the image element is assigned the source value of "undefined" and of course no image is named "undefined". */ document.getElementsByTagName('img')[0].src = jackhammers[curJackhammer].src; if(curJackhammer == 0) direction = "up"; else if(curJackhammer == 10) direction = "down"; document.getElementsByTagName('img')[0].src = jackhammers[curJackhammer]; } function startBouncing() { if(begin) clearInterval(begin); begin = setInterval("bounce()",90); } /* ]]> */ </script> </head> <body> <h1> Jackhammer Man </h1> <p> <img src="jackhammer0.gif" height="113" width="100" alt="Image of a man with a jackhammer." /> </p> <form action="" enctype="text/plain"> <p> <input type="button" value="Start Bouncing" onclick="startBouncing();" /> <input type="button" value="Stop Bouncing" onclick="clearInterval(begin);" /> </p> </form> </body> </html> My teacher insists that the above code is valid (straight out of our book). He says this because (I'm guessing) it runs okay in Firefox and other browsers. It also throws a ton of error messages in Chrome and makes no logical sense. We define the values of the jackhammer array as literal strings, and then the book instructs us to change the source of the image element on the page to jackhammers[i].src. It then has us change the source of the image element again, correctly at the end of the function. It also has us create a useless variable: "direction" (and I say useless because we never use it, it is just fluff I guess). On a side note, would some of you guys like to check out this animation I created here and let me know what you think. Thanks guys. I am not super familiar with code - I can easily take code and with a little direction get the desired end result so anyone who can help me with this it will be VERY appreciated. I don't even know what terms to search in order to create a page that I am looking for.... So here goes: I want to model our distributor page after a R E D K E N.com Distributor Locator Page. Here is what happens.... There is a drop down menu of the 50 states, and when you select the state the table of information below changes. screen shots below I am sure this is fairly easy to resolve, however I don't know where to begin. Thank You in advance for your time. Kristi I'm getting 'XMLSerializer is undefined' when I used the below code snippet in Java script. var xmlDoc=xmlhttp.responseXML; var Xml2String=xmlhttp.responseXML.xml; if (xmlDoc.xml) { Xml2String=xmlDoc.xml; }else{ Xml2String= new XMLSerializer().serializeToString(xmlDoc); } Please help me to solve this problem? Thanks in advance. airwindjai. Hello I'd really appreciate some help please, no other forum seems to have an answer for this. Example : I have a file called values.asp and in that file are 100 different variables all assigned a specific number. I also have a results.asp file or a simple html page. The target is to read a specific variable in the values.asp file and then display it in another asp file or standard HTML file using Javascript's document.write(variablename); method. So in other words, i wish to fetch a specific variables value from values.asp and show it in another asp file or a simple html file using javascript. Your help will be very much appreciated. Thanks! Ron the title kind of sums it up... if I have an array of equations (I'm guessing they should be strings but they don't have to be) and a user-defined variable can that variable be used for the "x" in the equations? I already did the easy part ... Code: <!DOCTYPE html> <html> <head> </head> <body> <input onkeyup="solve(this.value)" /><br> <input id="box0" /><br> <input id="box1" /><br> <input id="box2" /><br> <script type="text/javascript"> var equations=["(x*9/5)+32","x+273.15","x-50*(8/13)"] function solve(val){ for (var i = 0; i < equations.length; i++) { document.getElementById("box"+i).value= //ummm... } } </script> </body> </html> This post will contain a few guidelines for what you can do to get better help from us. Let's start with the obvious ones: - Use regular language. A spelling mistake or two isn't anything I'd complain about, but 1337-speak, all-lower-case-with-no-punctuation or huge amounts of run-in text in a single paragraph doesn't make it easier for us to help you. - Be verbose. We can't look in our crystal bowl and see the problem you have, so describe it in as much detail as possible. - Cut-and-paste the problem code. Don't retype it into the post, do a cut-and-paste of the actual production code. It's hard to debug code if we can't see it, and this way you make sure any spelling errors or such are caught and no new ones are introduced. - Post code within code tags, like this [code]your code here[/code]. This will display like so: Code: alert("This is some JavaScript code!") - Please, post the relevant code. If the code is large and complex, give us a link so we can see it in action, and just post snippets of it on the boards. - If the code is on an intranet or otherwise is not openly accessible, put it somewhere where we can access it. - Tell us any error messages from the JavaScript console in Firefox or Opera. (If you haven't tested it in those browsers, please do!) - If the code has both HTML/XML and JavaScript components, please show us both and not just part of it. - If the code has frames, iframes, objects, embeds, popups, XMLHttpRequest or similar components, tell us if you are trying it locally or from a server, and if the code is on the same or different servers. - We don't want to see the server side code in the form of PHP, PERL, ASP, JSP, ColdFusion or any other server side format. Show us the same code you send the browser. That is, show us the generated code, after the server has done it's thing. Generally, this is the code you see on a view-source in the browser, and specifically NOT the .php or .asp (or whatever) source code. I'm trying to get my Client Side Firefox DHTML app to display a list of eBooks. For this, i have the following files F:\Textbooks.html F:\eBooks.txt F:\FirstBook.txt F:\SecondBook.txt F:\ThirdBook.txt textbooks.html is my DHTML app eBooks.txt is the Library file with a listing of all of my eBooks. Inside of eBooks.txt is the following data: ----------------- FirstBook.txt, SecondBook.txt, ThirdBook.txt, ----------------- FirstBook.txt to ThirdBook.txt are my actual ebooks. The problem that i'm having is that When i try to click on any buttons other than the FirstBook button, i get the following error: ---------------------------------- Error: unterminated string literal Source File: file:///F:/Textbooks.html Line: 1, Column: 10 Source Code: LoadEbook(' ---------------------------------- So, unlike clicking on the FirstBook button, these other buttons do not load the eBook data into the DIV for displaying the eBook data. I use the DOM insepector to checkout the DOM of the button code, and it seems like whitespace maybe is the problem. However, i have removed whitespace from the HTMLdata string, and that's not fixing the problem. did i forget something silly? LOL i'm using FireFox 3.5 to develop this App. So obviously this will not work with anything other than Gecko Based browsers. here is my HTML code: <html> <head> <script language="JavaScript"> var eBookLibrary = "eBooks.txt"; var SystemPath = "f:" + String.fromCharCode(92) function Init() { // Initialize the eBook reader document.getElementById("EbookCanvas").style.visibility = "hidden"; document.getElementById("EbookToolbar").style.visibility = "visible"; document.getElementById("FileManager").style.visibility = "visible"; // Load the List of eBooks in the Library LoadBookList(); } function UpdateEbookList() { // Update the Library of Ebooks alert("Updating eBook Library"); // Go back to the File Manager, and Reload the List of Ebooks LoadBookList(); } function LoadBookList() { // This will load the list of books that are available var EbookList = LoadFromDisk(SystemPath + eBookLibrary); var EbookListArray = EbookList.split(","); for(var x = 0; x < EbookListArray.length -1; x++) { // Strip the Filename Extension off of the eBook File Name // The Name of the Book is always the first Index in the Array var BookName = EbookListArray[x].split("."); // Remove the weird whitespace - it screws things up...i think... BookName[0] = BookName[0].replace(/(^\s*|\s*$)/g, ""); var HTMLdata = HTMLdata + "<input type='button' value='" + "FirstBook" + "'" + " onClick=LoadEbook('" + EbookListArray[x] + "');><br>"; } // For some ****ed up reason the first string always generates an 'undefined' even though it's nonsense // So just delete that from the HTMLdata string, because it's just ugly - LOL HTMLdata = HTMLdata.replace("undefined", ""); HTMLdata = HTMLdata.replace("", " "); // Write the HTML data to the DIV document.getElementById("FileManager").innerHTML = HTMLdata; } function LoadEbook(EbookName) { // Hide the File Manager and Show the Ebook Canvas document.getElementById("FileManager").style.visibility = "hidden"; document.getElementById("EbookCanvas").style.visibility = "visible"; document.getElementById("EbookToolbar").style.visibility = "visible"; // Load the Ebook content into the Ebook Reader Pannel var EbookContent = LoadFromDisk(SystemPath + EbookName); document.getElementById("EbookCanvas").innerHTML = EbookContent; } function LoadFromDisk(filePath) { if(window.Components) try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile); file.initWithPath(filePath); if (!file.exists()) return(null); var inputStream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream); inputStream.init(file, 0x01, 00004, null); var sInputStream = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(Components.interfaces.nsIScriptableInputStream); sInputStream.init(inputStream); return(sInputStream.read(sInputStream.available())); } catch(e) { //alert("Exception while attempting to load\n\n" + e); return(false); } return(null); } </script> </head> <body onLoad="Init();"> <div id="FileManager" style="position: absolute; top: 0px; left: 0px; visibility: visible;"> The eBook Library's List of Books will be listed here. Click on one to open it in the eBook Reader </div> <br> <div id="EbookCanvas" style="position: absolute; top: 0px; left: 0px; visibility: hidden;"> </div> <br> <div id="EbookToolbar" style="position: absolute; top: 100px; left: 0px;"> <input type="button" value="Open" OnClick="Init();"> <input type="button" value="Update" OnClick="UpdateEbookList();"> <input type="button" value="Exit" OnClick="MainMenu();"> </div> </body> </html> Hi all, I hope someone can advise whether such a script exists for what am wanting to do. From time to time, I need to send password information or login details and password information to some users. At the moment, am doing it via email with a subject named FYI and the body of the email basically just contain the login and the password or in some case, just the password. What am wanting to know is whether I can put these information into a HTML file which contains an obfuscated Javascript with a button that a user will click that will prompt for his login information and then will display the password. In its simplest form, I guess I am looking for a Javascript that will obfuscate a HTML file that contains the password. Anyway, hopefully someone understand what am looking for. I found some website that offers such service as obfuscating a HTML file but am hoping it can be done via a Javascript so it is at least "portable" and I do not have to be online. Any advice will be much appreciated. Thanks in advance. Hey everyone here is my code for looking up a city, and state by zip code. I am getting no errors and i believe it should work, but the code does not seem to want to function. Any ideas? Here is my code: <!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>City and State Lookup</title> <style type="text/css"> h1 { font-family:Arial; color:navy; } p, td { font-family:arial; font-size:11px; } </style> <script type="text/javascript"> /* <![CDATA[ */ var httpRequest = false; function getRequestObject() { try { httpRequest = new XMLHttpRequest(); } catch (requestError) { try { httpRequest = new ActiveXObject ("Msxm12.XMLHTTP"); } catch (requestError) { try { httpRequest = new ActiveXObject ("Microsoft.XMLHTTP"); } catch (requestError) { window.alert("Your browser does not support AJAX!"); return false; } } } return httpRequest; } function updateCityState() { if (!httpRequest) httpRequest = getRequestObject(); httpRequest.abort(); httpRequest.open("get","zip.xml"); httpRequest.send(null); httpRequest.onreadystatechange=getZipInfo; } function getZipInfo() { if (httpRequest.readyState==4 && httpRequest.status == 200) { var zips = httpRequest.responseXML; var locations = zips.getElementsByTagName("Row"); var notFound = true; for (var i=0; i<locations.length; ++i) { if (document.forms[0].zip.value == zips.getElementsByTagName( "ZIP_Code")[i].childNodes[o].nodeValue) { document.forms[0].city.value = zips.getElementsByTagname( "City") [i].childNodes[0].nodeValue; document.forms[0].state.value = zips.getElementByTagName( "State_Abbreviation")[i].childNodes[0].nodeValue; notFound = flase; break; } } if (notFound) { window.alert("Invalid ZIP code!"); document.forms[0].city.value = ""; document.forms[0].state.value = ""; } } } /* ]]> */ </script> </head> <body> <h1>City and State Lookup </h1> <form action=""> <p>Zip code <input type="text" size="5" name="zip" id="zip" onblur="updateCityState()" /></p> <p>City <input type="text" name="city" /> State <input type="text" size="2" name="state" /></p> </form> </body> </html> I am trying to set up a looping structure that tests to see if the user enters a value. If the textbox is null then a global variable is false otherwise a checkbox is checked and the global variable is true. below is what i have done so far, please assist me. var isValid = false; window.onload = startForm; function startForm() { document.forms[0].firstName.focus(); document.forms[0].onsubmit = checkEntries; alert("You have been added to the list") } function checkEntries() { var menus = new Array(); var formObject = document.getElementsByTagName('*'); for (var i=0; i < formObject.length; i++){ if (formObject[i] == "myform") menus.push(formObject[i]); if (document.forms[0].firstName.value.length==0 || document.forms[0].firstName.value.length == null){ isValid= false; alert("Please enter a first name"); } else (document.forms[0].check0.checked=true); isValid=true; if (document.forms[0].lastName=="" || document.forms[0].lastName== null){ alert("Please enter a last name"); isValid = false; } else (document.forms[0].check1.checked=true); isValid=true; if (document.forms[0].email=="" || document.forms[0].email== null) { alert("Please enter a valid email"); } else return (document.forms[0].check0.checked=true); isValid=true; if (document.forms[0].bDate=="" || document.forms[0].bDate== null) { isValid=false; alert("please make sure you enter a valid birth date."); } else (document.forms[0].check0.checked=true); isValid=true; } } here is the form html... <form name="myform" > <input type="checkbox" name="check0" class="check0" id="check0" > First: <input type="text" name="firstName" id="firstName"> <BR> <input type="checkbox" name="check1" class="check1" id="check1" > Last: <input type="text" name="lastName" id="lastName" ><BR> <input type="checkbox" name="check2" class="check2" id="check2" > E-Mail: <input type="text" name="email" id="email"> <BR> <input type="checkbox" name="check3" class="check3" id="check3" > Birthday (mm/dd/yyyy): <input type="text" name="bDate" id="bDate"> <BR> <input type="submit" value="Join our mailing List" /> </form> |