JavaScript - Help Needed With Checkbox/dropdown Code.
Hello everyone. I have been trying 2 days straight to figure out how to make this script work. Basically I am trying to have a hidden checkbox with a drop down menu. I want the user to be able to choose 0-9 where 0 the check box will not be checked and 1-9 if picked from the dropdown menu it will automatically check the hidden box. Here is the closest string of code I could find out there to help me figure it out but I am having no luck. The closest I got was....well I never really figured out how to make it work. Can someone please help me? Thanks.
<script type="text/javascript"> function checkUncheck (selected) { var checkBox = document.getElementById("box"); if ((selected == 2) || (selected == 3)) { checkBox.checked = "checked"; } if ((selected == 0) || (selected == 1)) { checkBox.checked = "false"; } } </script> <form id="frm"> <table> <tr> <td><input type="checkbox" id="box" checked="false"/></td> <td> <select id="sel0" onchange="checkUncheck(this.selectedIndex)"> <option value="zero">zero</option> <option value="one">one</option> <option value="two">two</option> <option value="three">three</option> </select> </td> </tr> </table> </form> Similar TutorialsNeed a javascript function... If a checkbox is checked, then corresponding dropdown selection is must... Please help me with this... Thanks Reply With Quote hello everyone im coding a website at the moment using aspx and i have came to a snag. im trying to make a dropdown list which is populated by an array call my chaletDetails.aspx page - each item in the array will be directed to this page. ive diffled abit, but the more i do the more im afraid of breaking something lol. if someone could maybe look at the code and show me how this could be achieved id appriciate it very much. The code i have for my dropdown list is as follows... this is in divResorts.js var resorts = new Array("Adelboden", "Auron", "Oppdal", "Las Lenas", "La Pierre St Martin", "Val Ceneis", "Les Menuires", "Champex-Lac", "Puy St Vincent"); function populateSelectList() { var mystring = document.getElementById('divResort').innerHTML mystring += "<h4>Our Resorts</h4><select name='resorts'>" mystring += "<option>Choose a Resort</option>" for (i = 0; i < resorts.length; i++) { mystring += "<option value='" + resorts[i] + "'>" mystring += resorts[i] + "</option>" } mystring += "</select>" mystring += "<h4>Our Chalets</h4>" document.getElementById('divResort').innerHTML = mystring } within the body i have this called as: <div id="divResort"> <script type="text/javascript">populateSelectList();</script> </div> This code is designed to send people either to List 1 or List 2 in the Aweber form. At this time, I cannot make the uncheck go to List 2 to receive that thankyou email. Can you tell me what is wrong??? Check--Yes I would like to subscribe--List 1 email--thank you uncheck--No, I do not want to subscribe--List 2--you need more information I am omitting the top of the Aweber code before <body>-- <script language="javascript"> function magCheck(){ var magcheckbox = document.MainForm.magcheckbox.checked; if(magcheckbox == true){ document.getElementById("keylivingwell").value = '1355523361' document.getElementById("redirect").value = 'http://www.aweber.com/thankyou-coi.htm?m=text'; }else if(magcheckbox == false){ document.getElementById("keylivingwund").value = '1357528764' document.getElementById("redirect").value = 'http://www.aweber.com/thankyou-coi.htm?m=text'; } } </script> { } </style> <form method="post" class="af-form-wrapper" action="http://www.aweber.com/scripts/addlead.pl" > <div style="display: none;"> <input type="hidden" id="meta_web_form_id" name="meta_web_form_id" value="1355523361" /> <input type="hidden" name="meta_split_id" value="" /> <input type="hidden" name="listname" value="keylivingwell" /> <input type="hidden" name="redirect" value="http://www.aweber.com/thankyou-coi.htm?m=text" id="redirect_77879d6b0d1bc03d212e86d72e1eae3c" /> <input type="hidden" name="meta_adtracking" value="Key_to_Living_Well_in_Retirement" /> <input type="hidden" name="meta_message" value="1" /> <input type="hidden" name="meta_required" value="name,email" /> <input type="hidden" name="meta_tooltip" value="" /> </div> <div id="af-form-1355523361" class="af-form"><div id="af-header-1355523361" class="af-header"><div class="bodyText"><p> Yes, thank you, I would like</p> <p> a copy of the Report!</p></div></div> <div id="af-body-1355523361" class="af-body af-standards"> <div class="af-element"> <label class="previewLabel" for="awf_field-25981213">Name: </label> <div class="af-textWrap"> <input id="awf_field-25981213" type="text" name="name" class="text" value="" tabindex="500" /> </div> <div class="af-clear"></div></div> <div class="af-element"> <label class="previewLabel" for="awf_field-25981214">Email: </label> <div class="af-textWrap"><input class="text" id="awf_field-25981214" type="text" name="email" value="" tabindex="501" /> </div><div class="af-clear"></div> </div> <div class="af-element buttonContainer"> <input name="submit" id="af-submit-image-1355523361" type="image" class="image" style="background: none;" alt="Submit Form" src="http://www.aweber.com/images/forms/modern/blue/button.png" tabindex="502" /> <div class="af-clear"></div> </div> <div class="af-element privacyPolicy" style="text-align: center"><p><a title="Privacy Policy" href="http://www.aweber.com/permission.htm" target="_blank">We respect your email privacy</a></p> <div class="af-clear"></div> </div> <div class="af-element poweredBy" style="text-align: center; font-size: 9px;"><p>Powered by <a href="http://www.aweber.com" title="Email Marketing Services">AWeber</a> <a href="http://www.aweber.com" title="Email Marketing Services">Email Marketing Services</a></p> <div class="af-clear"></div> </div> </div> <div id="af-footer-1355523361" class="af-footer"><input id="magcheckbox" name="magcheckbox" onclick="magCheck();" type="checkbox" value="1" checked> <div class="bodyText"><p><span style="font-size: 14px;"> Yes, I would like to subscribe</span></p> <p><span style="font-size: 14px;"> to Baby Boomers Magazine.</span> </p></div></div> </div> <div style="display: none;"><img src="http://forms.aweber.com/form/displays.htm?id=jMysrKxMzMxsjA==" alt="" /></div> </form> <script type="text/javascript"> <!-- (function() { var IE = /*@cc_on!@*/false; if (!IE) { return; } if (document.compatMode && document.compatMode == 'BackCompat') { if (document.getElementById("af-form-1355523361")) { document.getElementById("af-form-1355523361").className = 'af-form af-quirksMode'; } if (document.getElementById("af-body-1355523361")) { document.getElementById("af-body-1355523361").className = "af-body inline af-quirksMode"; } if (document.getElementById("af-header-1355523361")) { document.getElementById("af-header-1355523361").className = "af-header af-quirksMode"; } if (document.getElementById("af-footer-1355523361")) { document.getElementById("af-footer-1355523361").className = "af-footer af-quirksMode"; } } })(); --> </script> I have looked at it so long time, I can't find it. Thanks for your help, Pat I am trying to use some JavaScript code that I found by searching the web, my goal is to have a form with a "required" checkbox to force my users to acknowledge they have read my "Terms and Conditions" section. The code that I found ALMOST works properly - it does pop-up the "Alert" window when the checkbox is blank and the submit button is clicked... however, if the user closes the Alert window in order to click the checkbox in compliance, the "submit.form" command is executed before they have a chance. In other words, there is no "pause" in the execution of the script to allow the user to make the correction by clicking the checkbox. Here is the code: Code: <script LANGUAGE="JavaScript"> <!-- function ValidateForm(form){ ErrorText= ""; if ( form.terms.checked == false ) { alert ( "Please check the Terms & Conditions box." ); return false; } if (ErrorText= "") { form.submit() }} --> </script> Here is the HTML for the checkbox: Code: <input name="terms" type="checkbox" value="Yes" /> Here is the HTML for the submit button that calls the function: Code: <input type="submit" value="Continue" onclick="ValidateForm(this.form)" /> I've searched for other examples of code to accomplish this objective, but I'm hoping for a quicker solution by coming to the experts who can see the flaw in this JavaScript. Thanks for any help, Rob Hello everyone, my 1st post here and my 1st day with javascript! I am having some problems with the below script: Code: <html> <head> <title></title> <script type="text/javascript"> var electronics = ["mobiles", "hi-fi"]; var entertainment = ["books", "dvds",]; function check(checkboxid) { document.getElementById(checkboxid).checked = "checked"; } function visiblox(arrDiv, hs) { var disp = (hs) ? "none" : "block"; for(var x = 0; x < arrDiv.length; x++) { document.getElementById(arrDiv[x]).style.display = disp; } } function chk(what, item) { if(item) { visiblox(what, false); } else { visiblox(what, true); } } </script> <style type="text/css"> <!-- .hide { display: block; } .hide { display: none; } --> </style> </head> <body> <img src="images/electronics.png" onclick="check('electronics');"> <input type="checkbox" id="electronics" onchange="chk(electronics, this.checked);" > <br> <input type="checkbox" onclick="chk(entertainment, this.checked);"> Entertainment<br> <br> <br> <div id="mobiles" class="hide">Mobiles</div><br> <div id="hi-fi" class="hide">Hi-Fi</div><br> <div id="books" class="hide">Books</div><br> <div id="dvds" class="hide">DVD's</div><br> </body> </html> Basically what happens is, when you select a checkbox it displays the relevant divs, this works fine with the entertainment checkbox in the code. What I am trying to achieve is use an image to trigger the checkbox (which will be hidden) and the run the chk code to display the divs What actually happens when you click the image the checkbox does become checked, however the divs do not display, if I uncheck the checkbox itself and then check the actual checkbox then it works. Basically getting very frustrated as I can't seem to see whats wrong! I am guessing that for some reason the check code stops the chk running, but I dont know why! Many thanks for any help A single letter is taken from each word in the sentence. Unlike before, either the first or last letter is taken. The letter taken is decided by which of the first or last is "greater" (e.g. "b" > "a", "c" > "b", etc.) Here are some examples based on the above rules: "hello" translates to "o" because "o" is greater than "h". "goodbye" translates to "g" because "g" is greater than "e". Full sentence example: "wazdee apple love bic nooo more end" This sentence will decrypt to "welcome". Complete the decryptB function so that it decrypts messages with the new scheme. Here are some examples: var decryptB = function(message) { // Your code here } var result1 = decryptB("wazdee apple love bic nooo more end") console.log(result1) // This should be "welcome" var result2 = decryptB("bria loud fuzu antidote") console.log(result2) // This should be "blue" Reply With Quote 01-20-2015, 09:41 PM #2 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,310 Thanks 82 Thanked 4,754 Times in 4,716 Posts See the page http://www.codingforums.com/rules.htm See rule 1.5 We helped you way way too much the last time you asked the first variant of this homework problem. This is really a very simple variation on that. And you don't even include the final version of the code you used last time, so somebody who didn't see the last answers would have to start all over again. Not very friendly to potential responders. What have you *TRIED*? If you came running here without even trying to solve this, shame on you. At least show what you have tried and explain what results you get and, if you can, what you think is going wrong. By the way: How is the user supposed to output an "a" character? You need an answer to that question, methinks. I am still learning javascript so forgive me if this question is a bad one, I am making scripts for Greasemonkey for a website I am a part of. One of the developers recently commented out (in the source code) a feature that was available before. It is a Football MMORPG game and it used to show college players 40 times but over the past month he commented out the tag that held the script function. I want to know if i can either A) write a js code that can remove the comment tag in the source code or B) write a code that will just add another tag under that and have that js function that was commented out valid. I tried something but ended up just having that function pasted onto the page instead of having it put into the source to have it read by the rest of the data.. here is what im talking about <TABLE width=800 cellspacing=0> <tr> <td colspan=3 style="FONT-SIZE: 11pt"> <b>Hometown:</b>Fort Hunt, VA<br> <b>Height:</b>6-0<br> <b>Weight:</b>206<br> <!--b>40 Time:</b><if rs("team_id")>0 or bRated then><=formatnumber(rs("forty"),2)><br><end if --> i just want to see if there was any way to just delete the comment out of it so i can get this feature again is all. Any help would be awesome... and sorry for the long post Hi I am new to programming and I am trying to write a piece of code, I need the output to be a whole random number, this is what I have up to now : <SCRIPT language = "JavaScript"> //generate a random number greater than or equal to 0.0 and less than 50.0 //and display it in an alert dialogue window.alert("getRoundedRandomNumber: " Math.round + Math.random()*50); </SCRIPT> </HEAD> <BODY> <STRONG>A test of the random number functions <BR></STRONG> <FORM NAME = "randomForm"> <INPUT TYPE = "button" NAME = "randomButton" VALUE ="Display Random Number" ONCLICK = "window.alert(getRoundedRandomNumber(50));"> </FORM> can anyone advise me where I would put the Math.round function and how to make it work ? Thanks in advance I have a vendor delivered java script code that I am currently customizing. The original code involves a user when selects a "check box" option value , a small function is called titled "VerifyAcctType". Currently when a user selects the check box some values are defaulted into the form. Now to this function code below i have to add logic when user selects the same check box option FIRST a small pop up window should appear which lists two radio buttons"I Agree to terms" and "I do not agree to terms" options , user need to select one of the options in the pop up to proceed. If the user agrees to terms then the control should go back to the "VerifyAcctType" function and proceed with remaining steps like before else if the user selects "I do not agree" the logic should not proceed further in "VerifyAcctType" function. Here is the current code tied to VerifyAcctType function ============================================== function VerifyAcctType(win,type) { var AcctType var ThisWindow var ThisForm if (win == "ADD") { ThisWindow = AddAccountWind ThisForm = AddAccountWind.document.addform } else if (win == "CHG") { ThisWindow = ChangeAccountWind ThisForm = ChangeAccountWind.document.chgform } if (type == "P") { <<I NEED NEW CODE HERE FOR THE POPUP>> Maccttype = type ThisForm.description.value = "My Company" ThisForm.comp_id.value = "1234567" ThisForm.comp_id.disabled = true } else { Maccttype = type ThisForm.description.value = "" ThisForm.comp_id.value = "" ThisForm.comp_id.disabled = false } } I am a java script beginner , any help is appreciated. hey guys. i need a js code that redirects to a flash page or to a non flash page after detecting the browsers plugin abilities and if it has flash or not. any help would be appriciated. cheers Can someone please suggest a good (and simple) code for password protecting one page on a site? I have a plan room for blueprints on my site. There will be multiple jobs at a given time and I need a page where we can give out a password to get the plans. Once the person logs in with user name and password for that day, he would then see file folders with the name of each job next to it. When he chooses a job, he clicks the folder to display a list of plans. If you can help with this or point me in a good direction, it would be greatly appreciated. Thanks for your help! Please where do I need to look to find such a script? I’ve been looking for 3 days now and I can’t find something that will have all of those. I need a floating horizontal dropdown menu, and submenu with mouse over description of the site. EX: menu 1 On the road ------- --------Restaurant .... .... ... .... ... .... .... .... ... .Mama house (home made cooking) .... .... ... .... ... .... .... .... ... .All fast food (only fast food get carb) .... .... ... .... ... Motel .... .... ... .... ... .... .... .... ... .No fleas motel (bugs free motel) .... .... ... .... ... .... .... .... ... .Pet free ( no pet allowed) Car rental Well I am sure you get the ideal. Where do I need to look or what would be the kind of scrip for that ? Java, html, css…. Please tell me to find the proper code for what I need. thanks Hello all. I need desperate help with this. The code below is two drop down menus where if you pick one of the values in the first drop down menu and pick the same exact value in the second drop down menu then it will give you an error stating that you can only select that value once. Example: if i choose T2 on the first drop down menu and select T2 on the second drop down it will print an error stating that you need to select another option. Here is where I need help. I want to have one of the drop down menus on one page named p1.html and have the other drop down on another page called p2.html. I need a solution on how to pass the information from the first drop down on p1.html to p2.html so it will know which was chosen on p1.html can anyone please help? Here is the code Code: <html> <title> hi </title> <head> </head> <body> First Choice: <select name="ThursAM_First" size="1" id="ThursAM_First" onchange="return no_dupes(this,ThursAM_Second)"> <option value="" selected>• choose •</option> <option value=""></option> <option value="T1">T1</option> <option value="T2">T2</option> <option value="T3">T3</option> <option value="T4">T4</option> </select> Second Choice: <select name="ThursAM_Second" size="1" id="ThursAM_Second" onchange="return no_dupes(this,ThursAM_First)"> <option value="" selected>• choose •</option> <option value=""></option> <option value="T1">T1</option> <option value="T2">T2</option> <option value="T3">T3</option> <option value="T4">T4</option> </select> </html> <script type="text/javascript" src="new.js"></script> Here is the javascript code that will give you an error if you select the same value twice... Code: function no_dupes(oSelect, oSelect2) { var selval = oSelect.options[oSelect.selectedIndex].v… var opt, i = 0; while (opt = oSelect2.options[i++]) if (opt.value && !opt.defaultSelected && (opt.selected && opt.value == selval)) { alert("\n Sorry, you already choose this point value for round 1. Please select another!\nThanks."); oSelect.selectedIndex = 0; return false; } } I may need to use a cookie but I have no idea how to that. Thank you all!!! Hey folks, Forgive me in advance if this is not the correct place to post this thread. I am a new member to this forum and need a little assistance. I have some script to create a quiz but need a little more detail. Does anyone know some code I can insert, and where to randomize the questions. Secondly if I have a test bank of 100 questions but want to limit the test to 20 questions what code would I need to insert that as well. Any assistance is very much appreciated. thank you. kenster Hi everyone, im no expert in coding but i manage to get this bit of code together using some free source stuff and put in the links to my images ect, the problem now is i need each picture to be different sizes and each one to have a clickable link but i am completely stumped heres the code Code: <html> <head> <script type="text/javascript"> <!-- var image1=new Image() image1.src="http://gohelp.org.uk/wp-content/uploads/2011/05/Charity-Rallies-World.png" var image2=new Image() image2.src="http://gohelp.org.uk/wp-content/uploads/2011/05/ROTW-logo.jpg" var image3=new Image() image3.src="http://gohelp.org.uk/wp-content/uploads/2011/05/Mongolia-Charity-Rally-Logo-Transparent.png" //--> </script> </head> <body> <center><img src="http://gohelp.org.uk/wp-content/uploads/2011/05/Charity-Rallies-World.png" name="slide" width="150" height="68" /></center> <script> <!-- //variable that will increment through the images var step=1 function slideit(){ //if browser does not support the image object, exit. if (!document.images) return document.images.slide.src=eval("image"+step+".src") if (step<3) step++ else step=1 //call function "slideit()" every 2.5 seconds setTimeout("slideit()",2500) } slideit() //--> </script> </body> </html> I want to insert a link into an email that opens a new window of a specific size. All of the scripts I find require some code to be inserted into the <head> tag of the page. Obviously this will not work since I am inserting the link into an email. Is there a JavaScript code for opening a popup window that's not dependent on <head> code?
This is the code that I'm presently using: Code: <script language="JavaScript" type="text/javascript"> <!-- function Cal(obj){ var total=0; var ticked=0; for (var zxc0=1;zxc0<obj['B'].length;zxc0++){ if (obj['B'][zxc0].checked){ total+=obj['B'].length-1; ticked+=zxc0; } } for (var zxc1=1;zxc1<obj['C'].length;zxc1++){ if (obj['C'][zxc1].checked){ total+=obj['C'].length-1; ticked+=zxc1; } } for (var zxc2=1;zxc2<obj['D'].length;zxc2++){ if (obj['D'][zxc2].checked){ total+=obj['D'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['E'].length;zxc2++){ if (obj['E'][zxc2].checked){ total+=obj['E'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['F'].length;zxc2++){ if (obj['F'][zxc2].checked){ total+=obj['F'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['G'].length;zxc2++){ if (obj['G'][zxc2].checked){ total+=obj['G'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['H'].length;zxc2++){ if (obj['H'][zxc2].checked){ total+=obj['H'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['I'].length;zxc2++){ if (obj['I'][zxc2].checked){ total+=obj['I'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['J'].length;zxc2++){ if (obj['J'][zxc2].checked){ total+=obj['J'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['K'].length;zxc2++){ if (obj['K'][zxc2].checked){ total+=obj['K'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['L'].length;zxc2++){ if (obj['L'][zxc2].checked){ total+=obj['L'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['M'].length;zxc2++){ if (obj['M'][zxc2].checked){ total+=obj['M'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['N'].length;zxc2++){ if (obj['N'][zxc2].checked){ total+=obj['N'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['O'].length;zxc2++){ if (obj['O'][zxc2].checked){ total+=obj['O'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['P'].length;zxc2++){ if (obj['P'][zxc2].checked){ total+=obj['P'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['Q'].length;zxc2++){ if (obj['Q'][zxc2].checked){ total+=obj['Q'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['R'].length;zxc2++){ if (obj['R'][zxc2].checked){ total+=obj['R'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['S'].length;zxc2++){ if (obj['S'][zxc2].checked){ total+=obj['S'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['T'].length;zxc2++){ if (obj['T'][zxc2].checked){ total+=obj['T'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['U'].length;zxc2++){ if (obj['U'][zxc2].checked){ total+=obj['U'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['V'].length;zxc2++){ if (obj['V'][zxc2].checked){ total+=obj['V'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['W'].length;zxc2++){ if (obj['W'][zxc2].checked){ total+=obj['W'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['X'].length;zxc2++){ if (obj['X'][zxc2].checked){ total+=obj['X'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['W'].length;zxc2++){ if (obj['W'][zxc2].checked){ total+=obj['W'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['X'].length;zxc2++){ if (obj['X'][zxc2].checked){ total+=obj['X'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['Y'].length;zxc2++){ if (obj['Y'][zxc2].checked){ total+=obj['Y'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['Z'].length;zxc2++){ if (obj['Z'][zxc2].checked){ total+=obj['Z'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AA'].length;zxc2++){ if (obj['AA'][zxc2].checked){ total+=obj['AA'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AB'].length;zxc2++){ if (obj['AB'][zxc2].checked){ total+=obj['AB'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AC'].length;zxc2++){ if (obj['AC'][zxc2].checked){ total+=obj['AC'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AD'].length;zxc2++){ if (obj['AD'][zxc2].checked){ total+=obj['AD'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AE'].length;zxc2++){ if (obj['AE'][zxc2].checked){ total+=obj['AE'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AF'].length;zxc2++){ if (obj['AF'][zxc2].checked){ total+=obj['AF'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AG'].length;zxc2++){ if (obj['AG'][zxc2].checked){ total+=obj['AG'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AH'].length;zxc2++){ if (obj['AH'][zxc2].checked){ total+=obj['AH'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AI'].length;zxc2++){ if (obj['AI'][zxc2].checked){ total+=obj['AI'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AJ'].length;zxc2++){ if (obj['AJ'][zxc2].checked){ total+=obj['AJ'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AK'].length;zxc2++){ if (obj['AK'][zxc2].checked){ total+=obj['AK'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AL'].length;zxc2++){ if (obj['AL'][zxc2].checked){ total+=obj['AL'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AM'].length;zxc2++){ if (obj['AM'][zxc2].checked){ total+=obj['AM'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AN'].length;zxc2++){ if (obj['AN'][zxc2].checked){ total+=obj['AN'].length-1; ticked+=zxc2; } } for (var zxc2=1;zxc2<obj['AO'].length;zxc2++){ if (obj['AO'][zxc2].checked){ total+=obj['AO'].length-1; ticked+=zxc2; } } obj['Score'].value='Sco '+ticked+'/'+total; } //--> </script> However, what this piece of code does is that, every radio button gets only 1 point. What I intended is that every subsequent radio button in each <td> garners incremental points by 1. Eg: Q1, 1st radio button gets 0pt, 2nd radio button gets 1pt, 3rd radio button gets 2pt. Does anyone have any idea how to implement that, all help are greatly appreciated! basically i have a form with lots of fields.. drop down boxes and textarea's and standard input text.. now what i need is a way to change all of these fields with a fetch button. i can get the value for the fields from the perl script on my server side. the form basicslly sends lots of fields to my perl script and saves each field of data into seperate text docs. now my customer would like to retrieve the data back to the form to change aspects of it to be resubmitted . i am struggling with the simplist of codes to set the value of the fields from a javascript variable any ideas please. here is the html code that i have PHP Code: <td valign="middle" valign="middle"> <input type="radio" name="gender" id="genderM" value="Male" /> Male <input type="radio" name="gender" id="genderFM" value="Female" /> Female </td> and here is the js funtion 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; } //mob //$jmob_pattern = '^\d{10}$j'; if(mobile.length != 10 || isNaN(mobile)){ error = 'Please Enter Your Mobile Number'; $j('#errormsg').html('<p class="errors">'+ error +'</p>'); return false; } if(email=='' || !isValidEmail(email)){ error = 'Please Enter Your Email Address'; $j('#errormsg').html('<p class="errors">'+ error +'</p>'); return false; } if(comment.length < 5){ error = 'Please Enter A Comment'; $j('#errormsg').html('<p class="errors">'+ error +'</p>'); return false; } return true; } Does anybody know how i check to see if the radio button is select and also can anybody tell me how i can check for an email in the correct format the function isValidEmail in the above alows emails to pass through if they are in this format aaa@aaa. i only want them to go through if they are aaa@aaa.com Thanks for your help if you give it |