JavaScript - Form Script - Help Please (easy)
Hi All
Javascript novice here so just need a bit of help. I'm sure it's something easy I have a form, attributes below: Code: <form id="frmOrder" name="input" method="post" onsubmit="return OnSubmitForm();"> I need the deposit input value to match the total input value if the weeks10 checkbox is ticked. The reason for this is my client requires full payment if this box is ticked. This must be done upon form submission. The reason for this is the email.php and payment.php submission pages collect the deposit value using $_POST and use that as the payment total Attributes for inputs below: Weeks10 checkbox: Code: <input type="checkbox" name="weeks10" id="weeks10" class="weeks10" /> Deposit input: Code: <input type="text" name="deposit" id="txtTotal3" readonly="readonly" size="2" value="0.00"></input> Totals input: Code: <input type="text" readonly="readonly" id="txtTotal" value="0.00" size="2" name="total"/> I'm using the following script: Code: <script type="text/javascript"> function OnSubmitForm() { if(document.input.weeks10[0].checked == true) { document.input.deposit.value = document.input.total.value; } return true; } function OnSubmitForm() { if(document.input.operation[0].checked == true) { document.input.action ="email.php"; } else if(document.input.operation[1].checked == true) { document.input.action ="payment.php"; } return true; } </script> The problem is, the second function works (email.php or payment.php action depending on radio selection). But the first one to adjust the total doesnt Now I know my script is wrong so would somebody be kind enough to lend me a hand? Thanks! *Edit - forgot to mention the example is live here if you need to see the full code. It's a fairly complicated form (for me atleast anyway) http://lake-form.carpbookings.co.uk Similar TutorialsHello, I have a script that makes a link a different color on click, i would like to add a hover color to the links that are NOT active. Script below. Thanks in advance! Code: function activate(el) { var links=document.getElementsByTagName("a"); for(i=0;i<links.length;i++) { if(links[i].className=="toggle") { links[i].style.color="#999"; } } el.style.color="#DF8700"; } I am after a script that will allow a calendar to pop up to select a date in UK date format. I have a page that has a form with three date fields so the script needs to be reusable. I have been told to use jquery but could not work out how to reuse or get the calendar to be a different size other than half the size of the full page screen! the whole sites CSS also got messed up using jquery for some reason, think maybe I had used the same CSS tags as jquery? So looking for a basic calendar script no-frills, short sweet reusable. :-) Can anyone suggest some? I don't know if this is in the correct section, sorry if it is not. I am creating a form in mailchimp for my site, I need to know if I can put the following all on one line instead of "last name" on one line and "input box" on another line. I know this is probably an easy fix for the pro's! <div class="mc-field-group" style="margin: 1.3em 5%;clear: both;overflow: hidden;"> <label for="mce-LNAME" style="display: block;margin: .3em 0;line-height: 1em;font-weight: bold;">Last Name <strong class="note-required">*</strong> </label> <input type="text" value="" name="LNAME" class="required" id="mce-LNAME" style="margin-right: 1.5em;padding: .2em .3em;width: 95%;float: left;z-index: 999;"> </div> Short version at bottom Need to add an array before an array to init thousands of arrays. Mostly worked out, just need to add an array before an array. ........Please check it out. Really want to finish this tonight or tomorrow. Alright, so two days later I finally have this portion working but its only because of the awesome people of this forum and unforunately these people thought I had some half decent grasp of javascript (which I don't) and so their answers were meant to solve my problem but each time I was left with no idea how to repeat what they did. So, I've learned a lot of extra stuff that I really could have done without in the effort to try and understand what they did. This is all well and good because I'm much farther than I am had I gone it alone (so thank you!) but please, anyone that posts an answer, could you try and explain a bit of how I might use your solution again. For example, today I was confused for about an hour because I didn't understand how [CODE]var newArray=[], a, i=0;CODE] worked but only after staring at it long enough and not finding anything on google related to "values inputed after array initialization" did I finally realized that these were not params of a new array but just new variables. Code: var alphabetArray =['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9','all1']; var a; var i=0; while(a=alphabetArray[i++]){ eval('var _img_'+a+' = []'); eval('var _h_'+a+' = []'); eval('var _r_'+a+' = []'); eval('var _m_'+a+' = []'); eval('var _yt_'+a+' = []'); } alert(_h_all1) and its working perfectly but I somehow I need to add Code: var pageNum = ['','p2_','p3_','p4_','p5_','p6_','p7_','p8_','p9_','p10_'] need to add pageNum to every alphabetArray so... _img_a = [],_img_p2_a = [], img_p3_a = [].... _img_p10_a = [] repeated for every variable in alphabetArray. _yt_p10_all1=[] Super short version Code: var alphabetArray =[letters/numbers]; var a; var i=0; while(a=alphabetArray[i++]){ eval('var _img_'+a+' = []'); } // works now I need to add 10 page prefixes before each var in alphabetArray Code: var pageNum = ['','p2_','p3_','p4_','p5_','p6_','p7_','p8_','p9_','p10_'] need to add pageNum to every alphabetArray so... _img_a = [],_img_p2_a = [], img_p3_a = [].... _img_p10_a = [] repeated for every variable in alphabetArray. _yt_p10_all1=[] Please explain how this might be possible in a way that your dog might understand. Hi Guys, Im new to JS and need some help.. I have a contact form on my webpage and i want to put in an alert box if people done enter a field. Below is the html i have for the form PHP Code: <form id="form" method="post" action="consultation.php" onsubmit="return validate(this)"> <p> <label>Name:</label> <input type="text" name="name" id="name" /> </p> <p> <label>Company:</label> <input type="text" name="company" id="company" /> </p> <p> <label>Email:</label> <input type="text" name="email" id="email" /> </p> <p> <label>Phone:</label> <input type="text" name="phone" id="phone"/> </p> <p style="margin-bottom:0px"> <input class="submit_btn" type="image" src="images/submit_btn.gif" name="submit" value="Submit" /> </p> </form> and here is the external Java Script file that iv made so far PHP Code: var nName = nForm['name']; var nCompany = nForm['company']; var nEmail = nForm['email']; var nPhone = nForm['phone']; if (nName.value.replace(/s/g, "").length < 1) { alert('Please enter your full name'); return false; } if (nCompany.value.replace(/s/g, "").length < 1) { alert('Please enter your company name'); return false; } if (!/^w+[w|.|-]{0,1}w*[w|.|-]{0,1}w*@w+[w|-]{0,1}w*[w|-]{0,1}w*.{1,1}[a-z]{2,4}$/.test(nEmail.value)) { alert('Please enter your correct email address'); return false; } if (!/[ds-]+$/.test(nPhone.value) || !/d{10}/.test(nMobile.value.replace(/[s-]/g, ""))) // must contain 10 digits; { alert('Please enter your correct phone number'); return false; } iv referenced this Java script file in the head of the html document.. Can anyone help me make this script please... THanks Hi guys, I recently bought a template for a site that has a mail form. But I can't seem to figure out where I'm supposed to put my e-mail address so that I receive the e-mails. The code below is the only file associated with the e-mail form that came with the template. It calls on a mail.php file; do I need to create that file? If so, what do I put in that file? Is there somewhere in this script where I should put my e-mail address? I'm a total newbie with this stuff (obviously). But I would be sooo grateful for any help. Code: function isValidEmailAddress(emailAddress) { var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i); return pattern.test(emailAddress); } /*FORM validation and div changing*/ $(document).ready(function() { /*email validatin*/ $("#submit").click(function() { var email = $("input#email").val(); if(!isValidEmailAddress(emailAddress)){ $("input#email").focus(); $("input#email").val('Enter a valid e-mail!'); return false; } }) /*form submit*/ $("form#contactForm").submit(function() { var email = $("input#email").val(); $.ajax({ url:'mail.php', type:'post', data: "email="+email, success: function(msg){ if (msg==0) { $("input#email").focus(); $("input#email").val('Some trouble on sending!'); } if (msg==1) { $("input#email").val('Thank you!'); } } }); return false; }); /*end formsubmit*/ }); Have a look at the java script feedback form on this page http://christmas.cre8tivebug.com/ the button is on the right hand side of the browser window.. when you click on it the feed back form shows up in the center of the screen and dims out the background.. does anybody know where i can get this script Thanks Hi Guys, I'm after a form saver script like this one? http://tf.dtbaker.com.au/form_saver/test_form.html The Email it sends is this: Quote: Thank you, your form has been saved you can now complete it later. To complete filling in your form, please click here or use the link below. http://tf.dtbaker.com.au/form_saver/...051c4eb3834ce9 Thank you Can anyone help as I can't get the source code for this... Dan Hello, Working With a touch screen, have created HTML page that has a custom keyboard for password input, no mouse or keyboard connected. Is there a way to enter keystrokes from the HTML into a (my form) text area (password) using Java. From the example below I am trying to put (1) into myform. <td><a class="Keys" type="password" target="myform">1</a></td> <!-- This Did not Work--> Thank You for any Info. Hi All, my first post on CodingForums I'm a javascript novice so looking for some help I'm using a handy little script from he http://www.mredkj.com/javascript/orderform.html On an order form he http://www.bluecoast.co.uk/test/order/form.php I've searched the net for hours and had a pop myself but I can't figure it out and it's driving me crazy Couple of things I'm after: 1. Need the "total price" to duplicate at the bottom of the form 2. Need exactly half the "total price" to show in both the deposit fields next to the total prices Hopefully that makes sense, can anybody give me a hand? Thanks in advance! Craig I have two seperate js files. One that houses the functions mylibrary.js and another that call the validated functions myform.js. I can not get the form to validate any data. The data just sits there and will not report errors. Any help would be greatly appreciated. Code: function valForm() { if(!isAlpha(document.myform.firstname.value)) { myform.firstname.focus(); return false; } if(!validEmail(document.myform.email.value)) { myform.email.focus(); return false; } if(!isRequired1(document.myform.options.value)) { myform.options.focus(); return false; } return true; } // JavaScript Document seperate js file mylibrary.js function isNumber(num) { return !(/\D/.test(num)); } function isAlpha(text){ return text.match(/\w+/) } function validEmail(email){ return email.match(/^([a-zA-Z0-9]{3,})(((\.|\-|\_)[a-zA-Z0-9]{2,})+)?@([a-z]{3,})(\-[a-z0-9]{3,})?(\.[a-z]{2,})+$/i ) } function isRequired1(){ if(myform.food.selectedIndex ==0) { alert("Please select from the drop-down list."); } } I am having some trouble with this form and I was hoping someone could help me with it. It is not returning any errors, it is simply not returning the results of the form fields. The clear form works, the redirect works, the layout is fine, just no results. I am just beginning to learn Javascripts and I know this is a pretty basic script, but could someone be so kind to show me what it is I am doing wrong and teach me the right way to do this? I know it has to be something very simple but I keep going over it and i can not see what I am doing wrong. Rather than just post a snipit of the code I included the whole form so I do not forget to include any information. Thanks guys, I really appreciate it! Code: <form name="evaluation" action="http://www.YOURURL.com/webformmailer.php" target="_self" method="post"><input value="Submission" name="subject" type="hidden" /><input value="evaluationreturn.html" name="redirect" type="hidden" /> <span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-weight: bold;"><br /> <table bgcolor="F7F5F2" border="0" cellpadding="0" cellspacing="0" width="456"> <tbody> <tr> <td><span style="color: rgb(40, 89, 161);">Comment 1</span><br style="color: rgb(40, 89, 161);" /> <br style="color: rgb(40, 89, 161);" /> <span style="color: rgb(40, 89, 161);">Comment 2</span><br style="color: rgb(40, 89, 161);" /> <br style="color: rgb(40, 89, 161);" /> <span style="color: rgb(40, 89, 161);">comment 3</span><br /> <br /> </td> </tr> <tr> <td height="28" valign="top"> <table style="width: 456px; height: 52px;" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td style="width: 137px; text-align: left; color: rgb(40, 89, 161);" class="text_1">Your name:</td> <td style="width: 40px;"><img src="images/spacer.gif" height="1" width="1" /></td> <td style="width: 271px;"><input name="yourname" class="form_1" type="text" /></td> </tr> </tbody> </table> </td> </tr> <tr> <td height="28" valign="top"> <table style="width: 456px; height: 52px;" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td style="width: 137px; text-align: left; color: rgb(40, 89, 161);" class="text_1">Business name:</td> <td style="width: 40px;"><img src="images/spacer.gif" height="1" width="1" /></td> <td style="width: 271px;"><input name="businessname" class="form_1" type="text" /></td> </tr> </tbody> </table> </td> </tr> <tr> <td height="75" valign="top"> <table style="width: 456px;" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="text_1" style="padding-top: 3px; width: 138px; text-align: left; vertical-align: middle; color: rgb(40, 89, 161);">Business Location:</td> <td style="width: 38px;"><img src="images/spacer.gif" height="1" width="1" /></td> <td style="width: 272px;"><textarea name="location" class="form_1"></textarea></td> </tr> </tbody> </table> </td> </tr> <tr> <td height="40" valign="top"> <table style="width: 456px;" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td style="padding-top: 3px; width: 138px; text-align: left; vertical-align: middle; color: rgb(40, 89, 161);" class="text_1">Business Hours:</td> <td style="width: 38px;"><img src="images/spacer.gif" height="1" width="1" /></td> <td style="width: 272px;"><textarea name="businesshours" class="form_1"></textarea></td> </tr> </tbody> </table> </td> </tr> <tr> <td height="28" valign="top"> <table style="width: 456px; height: 50px;" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td style="text-align: left; width: 143px; color: rgb(40, 89, 161);" class="text_1">Reservation required?</td> <td style="width: 34px;"><img src="images/spacer.gif" height="1" width="1" /></td> <td style="width: 271px;"><input name="reservation" class="form_1" type="text" /></td> </tr> </tbody> </table> </td> </tr> <tr> <td height="28" valign="top"> <table style="width: 456px; height: 50px;" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td style="width: 138px; text-align: left; color: rgb(40, 89, 161);" class="text_1">Reservation Telephone Number:</td> <td style="width: 39px;"><img src="images/spacer.gif" height="1" width="1" /></td> <td style="width: 271px;"><input name="reservationphone" class="form_1" type="text" /></td> </tr> </tbody> </table> </td> </tr> <tr> <td height="28" valign="top"> <table style="width: 456px; height: 50px;" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td style="width: 138px; text-align: left; color: rgb(40, 89, 161);" class="text_1">E-mail address:</td> <td style="width: 39px;"><img src="images/spacer.gif" height="1" width="1" /></td> <td style="width: 271px;"><input name="email" class="form_1" type="text" /></td> </tr> </tbody> </table> </td> </tr> <tr> <td height="28" valign="top"> <table style="width: 456px; height: 50px;" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td style="width: 138px; text-align: left; color: rgb(40, 89, 161);" class="text_1">Your contact number:</td> <td style="width: 39px;"><img src="images/spacer.gif" height="1" width="1" /></td> <td style="width: 271px;"><input name="yournumber" class="form_1" type="text" /></td> </tr> </tbody> </table> </td> </tr> <tr> <td height="91" valign="top"> <table style="width: 456px;" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td class="text_1" style="vertical-align: top; padding-top: 3px; width: 138px; text-align: left; color: rgb(40, 89, 161);">Select dates to perform evaluation: From/To <br /> Maximum of 30 days</td> <td style="width: 38px;"><img src="images/spacer.gif" height="1" width="1" /></td> <td style="width: 272px;"><textarea name="performdate" class="form_2"></textarea></td> </tr> <tr> </tr> </tbody> </table> </td> </tr> </tbody> </table> <br /> </span></span> <table style="text-align: left; width: 458px;" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td style="width: 220px; text-align: center;"> <p> <input value="Clear Form" onclick="reset(); return false;" type="reset" /></p> <input value="alpha" name="form_order" type="hidden" /> </td> <td style="width: 218px; text-align: center;"> <p> <input value="Submit" onclick="submit();" type="submit" /></p> <input value="alpha" name="form_order" type="hidden" /> </td> </tr> </tbody> </table> <span style="font-family: Arial,Helvetica,sans-serif;"><span style="font-weight: bold;"></span></span></form> "<scr'+'ipt type="text/javascript" src="js/val_feedback_Email.js<\/scr'+'ipt>" How should I call the js validation script for a feedback form that was document.written in a pop up? I have a page which contains a button. Onclick it produces a pop up window that contains a small feedback form produced by document.write. This much works. NOW I need to call the js validate script but nothing seems to work I tried this is the head of the page <script type="text/javascript" src="js/val_feedback_Email.js"> I tried this is the head of the doumnet.write part "<scr'+'ipt type="text/javascript" src="js/val_feedback_Email.js<\/scr'+'ipt>" How do I call the js script to validate the form in the pop up? Where if anywhere should it go? I'm stumped Any and all ideas welcomed LT THis is the start of my script Code: <script type="text/javascript"> var newWindow; function subWrite() { newWindow = window.open("","","status,height=500,width=700") //bring subwindow to front newWindow.focus(); //assemble content for new window var newContent = '<html><head><title>ACES UK. Send us your Email</title>'; newContent += '</head><body>'; newContent += '<form action="feedback.php" method="post" name="feedback_1" id="feedback_1" onsubmit="return validate(this.form)"'; I have a webpage in which my users complete a form in order to get through to page 2. I cannot use PHP to check as it must be on-the-fly checking. My idea was like the following: PHP Code: <script type="text/javascript"> function check(x) { if (x == 1) { document.write('<IMG SRC="img/'+x+'.jpg">'); } if (x == 2) { document.write('<IMG SRC="img/'+x+'.jpg">'); } if (x == 3) { document.write('<IMG SRC="img/'+x+'.jpg">'); } if (x == 4) { document.write('<IMG SRC="img/'+x+'.jpg">'); } } </script> And for the images to actually be PHP files that check further details of the user and insert details to DB. Then when the user clicks the next button it will check to see if all 4 users have loaded under that users details. However, I would much prefer it if I could use more PHP as I'm a Javascript n00b. Preferably I would like to use PHP to create unique keys for the images so that once I have obfuscated the javascript code the user will not figure out how to cheat the system even if they manage to reverse engineer the code. Is it possible to use PHP within javascript? E.g. PHP Code: <?php $pic = "picture.jpg"; ?> <script> function something(){ document.write('<IMG SRC="img/$pic">'); } </script> Or is this not at all possible? Edit: I know how much simpler that first script could have been, was just trying to simplify from my double as messy full script which will probably confuse you even more!!! hi there i got an website with lots of images on different foods and udner all the images i want to be able to put an html form and in javascript i want to be able to set an string or number for each different html for so if the user get the string or number right then move to an page i have set them to go to if they get it wrong it takes them to an errors page how would i do this in javascript i would like to have an different string or number for each html form on the page Code: <form id="apple" name="apple" method="post" action=""> <label>apple <input name="apple" type="text" id="apple" value="apple password here" /> </label> </form> <p> <input name="submit" type="submit" value="submit" /> thank you for your help Hello, I am trying to add radio buttons in this quiz script that i'm using, but when i change the drop down box to radio buttons the quiz script stops working, i.e it will not calculate the correct answers / percentage. I dont think i am correctly adding the input type "radio" and the script cannot recognise the value properly as i'am trying to make custom radio buttons from javascript / css. here is the script thats stopped working but how do i make the radio buttons send the correct value to the quiz script? Hope someone can help, i can add the css file if need be.. Code: <HTML> <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=yes;" /> <TITLE>Seventies Trivia Quizzes & Games</TITLE> <link rel="stylesheet" type="text/css" href="style.css" /> <script language=Javascript> <!-- function stopErrors(){ return true; } window.onerror=stopErrors; // --> </script> <script language="JavaScript1.1"> <!-- Hide from old browsers function quiz(form) { var i = 0 var result1=document.form1.answer1.selectedIndex var result2=document.form2.answer2.selectedIndex var result3=document.form3.answer3.selectedIndex var result4=document.form4.answer4.selectedIndex var result5=document.form5.answer5.selectedIndex var result6=document.form6.answer6.selectedIndex var result7=document.form7.answer7.selectedIndex var result8=document.form8.answer8.selectedIndex if (result1==0){ alert("Question #1 was not answered");} if (result2==0){ alert("Question #2 was not answered");} if (result3==0){ alert("Question #3 was not answered");} if (result4==0){ alert("Question #4 was not answered");} if (result5==0){ alert("Question #5 was not answered");} if (result6==0){ alert("Question #6 was not answered");} if (result7==0){ alert("Question #7 was not answered");} if (result8==0){ alert("Question #8 was not answered");} else { if (result1==3){i++} if (result2==3){i++} if (result3==1){i++} if (result4==4){i++} if (result5==3){i++} if (result6==1){i++} if (result7==1){i++} if (result8==2){i++} document.total.score.value = i var per = Math.round((i / 20) * 100) document.total.percent.value = per if (result1 != 3){document.form1.check1.checked = true} else {document.form1.check1.checked = false} if (result2 != 3){document.form2.check2.checked = true} else {document.form2.check2.checked = false} if (result3 != 1){document.form3.check3.checked = true} else {document.form3.check3.checked = false} if (result4 != 4){document.form4.check4.checked = true} else {document.form4.check4.checked = false} if (result5 != 3){document.form5.check5.checked = true} else {document.form5.check5.checked = false} if (result6 != 1){document.form6.check6.checked = true} else {document.form6.check6.checked = false} if (result7 != 1){document.form7.check7.checked = true} else {document.form7.check7.checked = false} if (result8 != 2){document.form8.check8.checked = true} else {document.form8.check8.checked = false} } } //--> </SCRIPT> <style type="text/css"> <!-- body { margin-left: 10px; margin-top: 10px; margin-right: 10px; margin-bottom: 10px; } --> </style></HEAD> <BODY> <FORM NAME="form1"><INPUT TYPE="hidden" NAME="check1"> <b>1. Who wrote the Eagles' 1972 hit "Take It Easy"?</b><BR><BR> <input type="hidden" SELECT NAME="answer1" SIZE=1> <fieldset class="radios"> <label class="label_radio" for="sample-radio-1a0"> <input name="sample-radio" id="sample-radio-1a0" NAME="radio" type="radio" SELECTED VALUE="0"/> CHOOSE AN ANSWER</label> <label class="label_radio" for="sample-radio-1a1"> <input name="sample-radio" id="sample-radio-1a1" NAME="radio" type="radio" VALUE="1" /> Randy Meisner</label> <label class="label_radio" for="sample-radio-1a2"> <input name="sample-radio" id="sample-radio-1a2" NAME="radio" type="radio" VALUE="2" /> J.D. Souther</label> <label class="label_radio" for="sample-radio-1a3"> <input name="sample-radio" id="sample-radio-1a3" NAME="radio" type="radio" VALUE="3" /> Jackson Browne & Glenn Frey</label> <label class="label_radio" for="sample-radio-1a4"> <input name="sample-radio" id="sample-radio-1a4" NAME="radio" type="radio" VALUE="4" /> Don Henley</label> </fieldset> </SELECT></FORM> <BR> <FORM NAME="form2"><INPUT TYPE="hidden" NAME="check2"> <b>1. Who wrote the Eagles' 1972 hit "Take It Easy"?</b><BR><BR> <input type="hidden" SELECT NAME="answer2" SIZE=1> <fieldset class="radios"> <label class="label_radio" for="sample-radio-2a0"> <input name="sample-radio" id="sample-radio-2a0" NAME="radio" type="radio" SELECTED VALUE="0"/> CHOOSE AN ANSWER</label> <label class="label_radio" for="sample-radio-2a1"> <input name="sample-radio" id="sample-radio-2a1" NAME="radio" type="radio" VALUE="1" /> Randy Meisner</label> <label class="label_radio" for="sample-radio-2a2"> <input name="sample-radio" id="sample-radio-2a2" NAME="radio" type="radio" VALUE="2" /> J.D. Souther</label> <label class="label_radio" for="sample-radio-2a3"> <input name="sample-radio" id="sample-radio-2a3" NAME="radio" type="radio" VALUE="3" /> Jackson Browne & Glenn Frey</label> <label class="label_radio" for="sample-radio-2a4"> <input name="sample-radio" id="sample-radio-2a4" NAME="radio" type="radio" VALUE="4" /> Don Henley</label> </fieldset> </SELECT></FORM> <BR> <FORM NAME="form3"><INPUT TYPE="hidden" NAME="check3"> <b>1. Who wrote the Eagles' 1972 hit "Take It Easy"?</b><BR><BR> <input type="hidden" SELECT NAME="answer3" SIZE=1> <fieldset class="radios"> <label class="label_radio" for="sample-radio-3a0"> <input name="sample-radio" id="sample-radio-3a0" NAME="radio" type="radio" SELECTED VALUE="0"/> CHOOSE AN ANSWER</label> <label class="label_radio" for="sample-radio-3a1"> <input name="sample-radio" id="sample-radio-3a1" NAME="radio" type="radio" VALUE="1" /> Randy Meisner</label> <label class="label_radio" for="sample-radio-3a2"> <input name="sample-radio" id="sample-radio-3a2" NAME="radio" type="radio" VALUE="2" /> J.D. Souther</label> <label class="label_radio" for="sample-radio-3a3"> <input name="sample-radio" id="sample-radio-3a3" NAME="radio" type="radio" VALUE="3" /> Jackson Browne & Glenn Frey</label> <label class="label_radio" for="sample-radio-3a4"> <input name="sample-radio" id="sample-radio-3a4" NAME="radio" type="radio" VALUE="4" /> Don Henley</label> </fieldset> </SELECT></FORM> <BR> <FORM NAME="form4"><INPUT TYPE="hidden" NAME="check4"> <b>1. Who wrote the Eagles' 1972 hit "Take It Easy"?</b><BR><BR> <input type="hidden" SELECT NAME="answer4" SIZE=1> <fieldset class="radios"> <label class="label_radio" for="sample-radio-4a0"> <input name="sample-radio" id="sample-radio-4a0" NAME="radio" type="radio" SELECTED VALUE="0"/> CHOOSE AN ANSWER</label> <label class="label_radio" for="sample-radio-4a1"> <input name="sample-radio" id="sample-radio-4a1" NAME="radio" type="radio" VALUE="1" /> Randy Meisner</label> <label class="label_radio" for="sample-radio-4a2"> <input name="sample-radio" id="sample-radio-4a2" NAME="radio" type="radio" VALUE="2" /> J.D. Souther</label> <label class="label_radio" for="sample-radio-4a3"> <input name="sample-radio" id="sample-radio-4a3" NAME="radio" type="radio" VALUE="3" /> Jackson Browne & Glenn Frey</label> <label class="label_radio" for="sample-radio-4a4"> <input name="sample-radio" id="sample-radio-4a4" NAME="radio" type="radio" VALUE="4" /> Don Henley</label> </fieldset> </SELECT></FORM> <BR> <FORM NAME="form5"><INPUT TYPE="hidden" NAME="check5"> <b>1. Who wrote the Eagles' 1972 hit "Take It Easy"?</b><BR><BR> <input type="hidden" SELECT NAME="answer5" SIZE=1> <fieldset class="radios"> <label class="label_radio" for="sample-radio-5a0"> <input name="sample-radio" id="sample-radio-5a0" NAME="radio" type="radio" SELECTED VALUE="0"/> CHOOSE AN ANSWER</label> <label class="label_radio" for="sample-radio-5a1"> <input name="sample-radio" id="sample-radio-5a1" NAME="radio" type="radio" VALUE="1" /> Randy Meisner</label> <label class="label_radio" for="sample-radio-5a2"> <input name="sample-radio" id="sample-radio-5a2" NAME="radio" type="radio" VALUE="2" /> J.D. Souther</label> <label class="label_radio" for="sample-radio-5a3"> <input name="sample-radio" id="sample-radio-5a3" NAME="radio" type="radio" VALUE="3" /> Jackson Browne & Glenn Frey</label> <label class="label_radio" for="sample-radio-5a4"> <input name="sample-radio" id="sample-radio-5a4" NAME="radio" type="radio" VALUE="4" /> Don Henley</label> </fieldset> </SELECT></FORM> <BR> <FORM NAME="form6"><INPUT TYPE="hidden" NAME="check6"> <b>1. Who wrote the Eagles' 1972 hit "Take It Easy"?</b><BR><BR> <input type="hidden" SELECT NAME="answer6" SIZE=1> <fieldset class="radios"> <label class="label_radio" for="sample-radio-6a0"> <input name="sample-radio" id="sample-radio-6a0" NAME="radio" type="radio" SELECTED VALUE="0"/> CHOOSE AN ANSWER</label> <label class="label_radio" for="sample-radio-6a1"> <input name="sample-radio" id="sample-radio-6a1" NAME="radio" type="radio" VALUE="1" /> Randy Meisner</label> <label class="label_radio" for="sample-radio-6a2"> <input name="sample-radio" id="sample-radio-6a2" NAME="radio" type="radio" VALUE="2" /> J.D. Souther</label> <label class="label_radio" for="sample-radio-6a3"> <input name="sample-radio" id="sample-radio-6a3" NAME="radio" type="radio" VALUE="3" /> Jackson Browne & Glenn Frey</label> <label class="label_radio" for="sample-radio-6a4"> <input name="sample-radio" id="sample-radio-6a4" NAME="radio" type="radio" VALUE="4" /> Don Henley</label> </fieldset> </SELECT></FORM> <BR> <FORM NAME="form7"><INPUT TYPE="hidden" NAME="check7"> <b>1. Who wrote the Eagles' 1972 hit "Take It Easy"?</b><BR><BR> <input type="hidden" SELECT NAME="answer7" SIZE=1> <fieldset class="radios"> <label class="label_radio" for="sample-radio-7a0"> <input name="sample-radio" id="sample-radio-7a0" NAME="radio" type="radio" SELECTED VALUE="0"/> CHOOSE AN ANSWER</label> <label class="label_radio" for="sample-radio-7a1"> <input name="sample-radio" id="sample-radio-7a1" NAME="radio" type="radio" VALUE="1" /> Randy Meisner</label> <label class="label_radio" for="sample-radio-7a2"> <input name="sample-radio" id="sample-radio-7a2" NAME="radio" type="radio" VALUE="2" /> J.D. Souther</label> <label class="label_radio" for="sample-radio-7a3"> <input name="sample-radio" id="sample-radio-7a3" NAME="radio" type="radio" VALUE="3" /> Jackson Browne & Glenn Frey</label> <label class="label_radio" for="sample-radio-7a4"> <input name="sample-radio" id="sample-radio-7a4" NAME="radio" type="radio" VALUE="4" /> Don Henley</label> </fieldset> </SELECT></FORM> <BR> <FORM NAME="form8"><INPUT TYPE="hidden" NAME="check8"> <b>1. Who wrote the Eagles' 1972 hit "Take It Easy"?</b><BR><BR> <input type="hidden" SELECT NAME="answer8" SIZE=1> <fieldset class="radios"> <label class="label_radio" for="sample-radio-8a0"> <input name="sample-radio" id="sample-radio-8a0" NAME="radio" type="radio" SELECTED VALUE="0"/> CHOOSE AN ANSWER</label> <label class="label_radio" for="sample-radio-8a1"> <input name="sample-radio" id="sample-radio-8a1" NAME="radio" type="radio" VALUE="1" /> Randy Meisner</label> <label class="label_radio" for="sample-radio-8a2"> <input name="sample-radio" id="sample-radio-8a2" NAME="radio" type="radio" VALUE="2" /> J.D. Souther</label> <label class="label_radio" for="sample-radio-8a3"> <input name="sample-radio" id="sample-radio-8a3" NAME="radio" type="radio" VALUE="3" /> Jackson Browne & Glenn Frey</label> <label class="label_radio" for="sample-radio-8a4"> <input name="sample-radio" id="sample-radio-8a4" NAME="radio" type="radio" VALUE="4" /> Don Henley</label> </fieldset> </SELECT></FORM> <BR> <BR><BR><HR> <P>That's it! Now click the "Submit" button to grade your Seventies music knowledge.<BR> <form name="total"> <INPUT TYPE="BUTTON" VALUE="Submit" onClick="quiz()"> <INPUT TYPE="button" VALUE="Reload Quiz" onClick='parent.location="javascript:location.reload()"'><BR><HR><BR>Results:<BR><BR> You scored <INPUT TYPE="TEXT" NAME="score" VALUE="" SIZE=5> out of <INPUT TYPE="TEXT" NAME="outof" VALUE="8" SIZE=5> questions correct.<BR><BR> Your Sco <INPUT TYPE="TEXT" NAME="percent" VALUE="" SIZE=3> %<BR><BR> <HR> </FORM> <script> var d = document; var safari = (navigator.userAgent.toLowerCase().indexOf('safari') != -1) ? true : false; var gebtn = function(parEl,child) { return parEl.getElementsByTagName(child); }; onload = function() { var body = gebtn(d,'body')[0]; body.className = body.className && body.className != '' ? body.className + ' has-js' : 'has-js'; if (!d.getElementById || !d.createTextNode) return; var ls = gebtn(d,'label'); for (var i = 0; i < ls.length; i++) { var l = ls[i]; if (l.className.indexOf('label_') == -1) continue; var inp = gebtn(l,'input')[0]; if (l.className == 'label_check') { l.className = (safari && inp.checked == true || inp.checked) ? 'label_check c_on' : 'label_check c_off'; l.onclick = check_it; }; if (l.className == 'label_radio') { l.className = (safari && inp.checked == true || inp.checked) ? 'label_radio r_on' : 'label_radio r_off'; l.onclick = turn_radio; }; }; }; var check_it = function() { var inp = gebtn(this,'input')[0]; if (this.className == 'label_check c_off' || (!safari && inp.checked)) { this.className = 'label_check c_on'; if (safari) inp.click(); } else { this.className = 'label_check c_off'; if (safari) inp.click(); }; }; var turn_radio = function() { var inp = gebtn(this,'input')[0]; if (this.className == 'label_radio r_off' || inp.checked) { var ls = gebtn(this.parentNode,'label'); for (var i = 0; i < ls.length; i++) { var l = ls[i]; if (l.className.indexOf('label_radio') == -1) continue; l.className = 'label_radio r_off'; }; this.className = 'label_radio r_on'; if (safari) inp.click(); } else { this.className = 'label_radio r_off'; if (safari) inp.click(); }; }; </script> <P>Ratings:<br><br> 90-100% - "I Just Want To Celebrate"<br> 80-89% - "I Want To Take You Higher"<br> 70-79% - "One Toke Over The Line"<br> 60-69% - "What's Going On"<br> 50-59% - "Stuck In The Middle With You"<br> 0-49% - "Ball of Confusion"<br> </blockquote> </BODY> </HTML> Hi coders, I have a form where customers can register thierselves by entering the relevant fields. There is a control() javascript which ckecks if everything on the form is ok before submitting it. Althugh IE applies the script for its every check, Firefox only applies the first check (first if statement) of the script. The rest is ignored. Here is the javascript code: Code: function control() { if (document.member.FirstName.value == ""){ document.member.FirstName.focus(); alert("Please fill the name field"); return false; } if (document.member.FirstName.value.length<2) { alert("Name field cannot be shorter than 2 characters."); document.member.FirstName.focus(); return false; } if (/[\d]/.test(document.getElementById("FirstName").value)) { alert("Entered numbers into the Name field"); return false; } if (document.member.LastName.value == ""){ document.member.LastName.focus(); alert("Please fill the Lastname field"); return false; } if (document.member.LastName.value.length<2) { alert("Lastname field cannot be shorter than 2 charcters. Please check again."); document.member.LastName.focus(); return false; } if (/[\d]/.test(document.getElementById("LastName").value)) { alert("Entered numbers into the Lastname field"); return false; } if (document.member.Address1.value.length<10) { alert("Address field contains less than 2 characters."); document.member.Address1.focus(); return false; } if (document.member.Username.value == ""){ document.member.Username.focus(); alert("Username field cannot be blank"); return false; } if (document.member.Address1.value == ""){ document.member.Address1.focus(); alert("Address field cannot be blank "); return false; } if (document.member.City.value == ""){ document.member.City.focus(); alert("City field cannot be blank"); return false; } if (document.member.Email.value == ""){ document.member.Email.focus(); alert("E-Mail field cannot be blank."); return false; } if (echeck(document.member.Email.value)==false){ document.member.Email.focus(); return false; } if (document.member.PhoneNumber.value == ""){ document.member.PhoneNumber.focus(); alert("Phone number field cannot be blank"); return false; } if (!/^\d*$/.test(document.getElementById("PhoneNumber").value)) { alert("Entered characters into the Phone Number field"); return false; } if (document.member.Pass.value == ""){ document.member.Pass.focus(); alert("Password field cannot be blank."); return false; } if (document.member.Pass2.value == ""){ document.member.Pass2.focus(); alert("Password confirmation field cannot be blank."); return false; } if (document.forms[0].Pass.value.length<6) { alert("Password field cannot contain less than 6 characters. Please check"); document.member.Pass.focus(); return false; } if (document.member.Pass.value != document.member.Pass2.value) { alert("Password and password confirmation fields are not identical. Please check "); document.member.Pass.focus(); return false; } if (!isTelNum(document.forms[0].PhoneNumber,'Telefon ')) return false; if (!isNum(document.forms[0].InternalPhoneNumber,'Internal Phone number')) return false; //if (!isValidEmail(document.forms[0].Email)) return false; return true; } Well its interesting that only the first check is taken into consideration. if (document.member.FirstName.value == ""){ The rest is not even seen. Even if you do not fill the rest of the form, the submit button tries to submit the form regardless what more needs to be checked. Here is the submit button: Code: <input type="submit" name="member" value="Register Me" id="member" onclick="return control()";> Any observations and comments are appreciated. Hello, I am trying to create simple Java Script form that will open a URL based on the contents entered into the form. The form shall consist of only a text box and submit button. A user will enter XXXX in the text box and click submit. The form would then load a URL consisting of http://www.company.com/XXXX I know this can be done because I had a code like this a few years back but I have lost it. I've been searching for over an hour, trying to figure this out. Any help would be grately appreciated. Thanks! What I am looking to do is auto-populate a number of forms based on what a user chooses as a starting date. For example: If a user enters 12/12/2009 I want the other fields to automatically populate with the next 2 weeks (12/13/2009, 12/14/2009, 12/15/2009 etc.) Anyone have a useful script that I can use given that these fields are formatted as dates? The idea is to save time by only having to fill in the first date in the timesheet. |