JavaScript - Jquery Realtime Order Form - Change Form Elements Depending On Selection
Hello
I've been struggling trying to get a small order form to work the way I want it to. Here is a link to the live page: http://www.watphotos.com/introductio...otography.html And here is the code in question: Code: <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script> <script type="text/javascript" charset="utf-8"> $(document).ready(function(){ var initial = 0 var total = 0; var services = 0; function addServices() { initial = 150 total = initial services = 0; $("input:checked").each(function(){ value = $(this).attr("value"); services += parseInt(value); }); } $(function() { addServices(); total += services; $("form").before('<p class="price"></p>') $("p.price").text("Total Price: US$" + total); }); $("input:radio, input:checkbox").click(function () { addServices(); total += services $("p.price").text("Total Price: US$" + total); }); }); </script> I have two questions... Question 1 How can I make this piece of script act a little smarter. Look at the order form, I'm catering for up to 4 people and providing lunch for them. If they select 3 people and the spaghetti bol for lunch, it's only adding $10 where it should be adding $30. Obviously this is simple multiplication but since the values in my form are prices it makes it a little tricky. I'm guessing an onselect on the first part of the form which changes the pricing of the other items would be the way to go, but how do I do this? Question 2 The "Total Price" is placed before the <form> tag by the script. This is ok but it's not where I want it. How can I position this text elsewhere in the document? Thanks in advance! Similar TutorialsI'm using the jquery plugin found here. I love the look but I have a form that uses functions like this: Code: function cascadeCountry(value) { if (document.getElementById("srchlookstate_province") != null) { http.open('get', 'cascade_search.php?a=country&v=' + value ); document.getElementById('srchlookstate_province').innerHTML=" "+loadingTag; http.onreadystatechange = handleResponse; http.send(null); } } So, when you select a country and it retrieves the state/province text input, the jquery css is not applied to it. Is there something I need to add to the code above or to the jquery initialization code he Code: $(function() { $("form.jqtransform").jqTransform(); }); I have recently installed google custom search on a page- using the iframe selection, so I can have control over the look of the page and it isn't a google branded page. The problem is- with JS disabled, this form doesn't work. However, the option to display results on a google hosted page does work. This is very important for accessibility for this site, so what I am wanting to do is have the basic search show ONLY if there is no JS enabled. But for everyone else- it displays as I intended. JS isn't my bread and butter, but I think it's the tool to use here. Could someone offer some guidance? Main Form Code: <div style="float:right"> <script type="text/javascript" src="/js/main.js"></script> <div id="searchBox" class="searchBoxTopLevelNav"> <form name="search" id="search" action="search.php?"> <label for="q" style="display:none";>Site Search</label> <input onclick="javascript:SearchClear(this);" onkeypress="javascript:OverrrideForms(this);" name="q" id="q" autocomplete="off" class="GoogleSearchTextBox" value="Search" /> <input name='btnG' onclick="javascript:SearchGoogle($(this).prev('input.GoogleSearchTextBox:first'));return false;" type='image' value='Search' src='../img/icons/search-gray.gif' alt='Go' align="top"/> </form> </div> Form to display only if JS is not enabled Code: <form action="http://www.google.com/cse" id="cse-search-box"> <div> <input type="hidden" name="cx" value="#" /> <input type="hidden" name="ie" value="UTF-8" /> <input type="text" name="q" size="31" /> <input type="submit" name="sa" value="Search" /> </div> </form> <script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&lang=en"></script> I'm still a relative noob and i'm wondering if anyone can help. items use a structured form, so any item in that category will display on the same form when selected i want to have the save button run its normal save on all items except 1 specific item - on the 1 item i want to have it function as a save as copy (while still having "save" as its visible text), the current code set in a drop down list is $options[] = array( 'text' => 'JSAVE', 'task' => $this->getName() . '.save'); $options[] = array( 'text' => 'Save as new project', 'task' => $this->getName() . '.save2copy', 'options' => array('access' => ($this->item->id > 0))); can anyone offer any suggestions? really stuck on this one Hello. The code below lets a user select a drop down option and a picture changes depending on the selection. I am trying to make it so when you select an option on the dropdown the picture shows up in the center of the screen and in the background behind the text. Here is the code. Code: <html> <head> <style type='text/css'> #txt {background-repeat:no-repeat;width:200px;height:200px;} </style> <script type='text/javascript'> function div_bg(team){ document.getElementById('txt').style.backgroundImage="url(images/" + team + ".jpg)"; } </script> </head> <body> <select name='team' onChange='div_bg(this.value);'> <option name='arsenal' value='arsenal'>Arsenal</option> <option name='liverpool' value='liverpool'>Liverpool</option> </select> <div id='txt'></div> </body> Thanks in advance!! Please help with the code details as to how this would be possible. Thanks. <form method="post" name="validate" action="internet_marketing_and_email_blasting_signup.php" enctype="multipart/form-data" onmouseover="change(event,'../images/submit1.png')" onmouseout="change(event,'../images/submit.png')" onkeyup="highlight(event)" onclick="highlight(event)"> I'm trying to write a progressively enhanced web application. I have an index page and a form with some select boxes and some radio buttons on a different php page. Before enhancement occurs, the form is accessible via regular links and everything works as expected. No issues. In the enhanced version of the application, the form is AJAXed into the index page. When this occurs, the select boxes in the form work perfectly. The radio buttons are initially unchecked and I can check one option as usual. However, once one is checked, clicking the other radio options does nothing. I am unable to check a different option. Anybody got a clue what the problem is? Using Chrome by the way. Firefox is the same as Chrome. In IE I can't even check a radio button the first time. Here's the code that's ajaxed in: Code: <label>First Time Buyer Status <!--These values can't be 1/0 because 0 stands for not set--> <input type="radio" name="FTB" id="FTBYes" value="1" <?php $M->checkFTBValue(1); ?> title=""/>First Time Buyer <input type="radio" name="FTB" id="FTBNo" value="2" <?php $M->checkFTBValue(2); ?> title=""/>Not First Time Buyer </label> The PHP script you see there checks if the value on the server matches the value of the radio button and echo's checked="checked" if true. I thought this could be causing the problem initially but the exact same code is used in the non-enhanced version and it works fine. I tried commenting it out anyway but it makes no difference. The only thing I can think of is that some javascript is preventing me from selecting a different radio option. That would explain why it works ok in the non-enhanced version because there is no JS there. I can't find anything that I've written that might cause this effect I'm using jQuerys form plugin on my pages. I'm going to try writing it out and see if that fixes anything. Any body ever experience a similar problem with this? In the mean time, is there a way I can check if any JS functions when I click on the radio button? Sorry if this is in the wrong forum, there's so many different languages involved, I hadn't a clue where to put it. I have a order form page and on submitting it opens a new web page that displays the order totals. Below is my code and most probably wrong but for me it seems logic. Please assist. Order Form: Code: <td colspan="1" height="120" align="left"> <select style="margin-left: 60px; background-color: #00FF77;" name="prod_bed_359" onchange="calculateValue(this.form)"> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select> R359</td></tr> New page I called a unction to print: Code: function itemsOrdered() { var beds = document.forms[2].prod_bed_359.value; document.write("<pre><strong>Description\t\tQuantity\tPrice</strong></pre>"); document.write("<pre>Doggie Bed\t\t" + beds + "</pre>"); } This is still basic as I need to get this right before adding the prices and totals which is also extracted from the order page. I have been hard at work coding a fancy JQuery form validation script. Problem is, when I run validation on my form, it seems to work, but no email is sent. But when I disable validation, the email sends just fine. I am fairly new to JavaScript, and need some help pinpointing where my error is. Here is the code. Code: // BEGIN JAVASCRIPT $(function(){ //original field values var field_values = { //id : value 'name' : 'your name', 'email' : 'your email', 'yourmessage' : 'I would like to inquire about' }; //inputfocus $('input#name').inputfocus({ value: field_values['name'] }); $('input#email').inputfocus({ value: field_values['email'] }); $('textarea#yourmessage').inputfocus({ value: field_values['yourmessage'] }); //form validation $('form').submit(function validateForm(){ return false }); // removing this return false seems to mess up validation $('#submit').click(function(){ //remove classes $('#sendamessage input').removeClass('error').removeClass('valid'); //ckeck if inputs aren't empty var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; var fields1 = $('#sendamessage input[type=text],#sendamessage textarea'); var error = 0; fields1.each(function(){ var value = $(this).val(); if( value.length<2 || value==field_values[$(this).attr('id')] || ( $(this).attr('id')=='email' && !emailPattern.test(value) ) ) { $(this).addClass('error'); // css class $(this).effect("shake", { times:3 }, 50); error++; } else { $(this).addClass('valid'); // css class } }); if(!error) { // this is where I get confused. How do I make this send the form? alert('Data sent'); }); } }); }); // END JAVASCRIPT <form method="post" action="" onsubmit="return validateForm()" > <input type="hidden" name="ccf_customhtml" value="1" /> <input type="hidden" name="success_message" value="Thank you for filling out our form!" /> <input type="hidden" name="destination_email" value="dauidus@gmail.com" /> <input type="hidden" name="required_fields" value="" /> <label for="name">Name</label> <input type="text" name="name" id="name" value="your name" /> <label for="email">Email</label> <input type="text" name="email" id="email" value="your email" /> <label for="yourmessage">Your Message</label> <textarea name="yourmessage" id="yourmessage" value="I would like to inquire about" style="margin-bottom:20px;" />I would like to inquire about</textarea> <input class="send submit" id="submit" type="submit" value="" style="position: relative; bottom: -70px; left: 25px; " /> </form> I am using a WordPress plugin to automatically send the contents of the form to email. It works without the javascript enabled. But when I turn on JS the form gets validated, but no email is sent. Please let me know if I should include anything else here... I've been looking at this code so much that I'm having a hard time doing it with fresh eyes. The problem page is on http://new.dauidusdesign.com/contact/. FYI, I am also looking to make this work with the 'request a quote' link on the same page. Cheers! -Dave I'm a long time lurker on here just barely created an account to ask this question. I work at a call center, and we use different webapps to fill out tickets. One I've used for a long time allows dynamically updating forms with javascript. I have a whole bunch of bookmarked javascript injections like: Code: javascript:if((top.detail.findObj('X31').value="Inquiry")!=""); That code will fill out most everything in that ticket, leaving me to fill in the details. I have one of those for all of the most common tickets, and can create and finish a ticket in less than 30 seconds when it takes others 3-4 minutes. I recently switched to a different system and I'm having trouble with my code. I'm a noob at javascript for sure, but I'm not new to programming. Anyway any pointers would be nice. The system we use doesn't allow me to see the source... I'm not sure how to explain it. It loads everything in a frame. In chrome I can right click then inspect element and get the ID but it the above javascript doesn't work. Examples: Old app source ex: Code: <label for="X31">Category:</label> was all i needed new app(before the body code is just code for the login form, etc): Code: <body onLoad="startit()" onUnload="stopit()"> </body> <div align="center" valign="center" id="LoadMessageID" style="position: relative; top:40%; color:#0069A5; font-size:100% ;"> <img src="/arsys/shared/images/Progress_NonModal-circle.gif" alt="wait image"/> Loading... </div> </html> formloader: Code: <form name="form1" action="/arsys/forms/bmcitsm/HPD:Incident+Management+Console/Default+User+View+(Support)/?cacheid=a22a36a8" method="post"> example of inspect element in chrome (something i want to change with javascript injection): Code: <input id="arid301602600" type="text" class="text " style="top:0; left:0; width:225; height:21;" readonly=""> Hello, I have a form that works out some basic math questions e.g. area etc. I run a function when a form field is updated to do the calculations, however I'd like to run a different calculation depending on which form element was updated. Is there a way to say something like: if (area1 was updated) { work out this calculation } if(area2 was updated) { work out this calculation } and so on? Thanks, Nicola Hello Folks, Here is my dropdown menu: Code: <select name="peeps"> <option value="Frank Tompson">Frank Tompson</option> <option value="Henry Wilson">Henry Wilson</option> <option value="Bill Kent">Bill Kent</option> <option value="Jessi McDonald"> Jessi McDonald</option> <option value="John Hays">John Hays</option> How can i make it so if i click on John Hays a JavaScript pop up will say Hello John Hays, and if i click on Bill Kent a popup will say hello Bill Kent and if i click on any other name nothing happens? From my main page, I have a dropdown-login box. Is it possible login form go to my user's control panel if the login was successful, or go to the login page if it's not? Ideally, I don't want to use a re-direct. Do I need to use ajax? Thank you! Hi Within a classic asp webform (using vbscript) I would like part of the form (input boxes within table structure) to be specific/displayed depending on the users selection from the combo box in the row above. I think the best solution would be using Javascript can anyone suggest a solution or example code? Many thanks Sarah Dear Javascript programmers, Do you have an example of a Javascript something like this: A dropdownlist with values "one" and "two". The radio button is not visible (as a start). - If you have selected "one" from the dropdown list, then a radio button will appear. - If you have selected "two" from the dropdown list, then a radio button will NOT appear. Thanks, Cornelis Gouda - The Netherlands Hi coders, I need to achieve two things upon making a selection from a drop down field: 1) Changing the background picture of a cell. 2) Changing the size of a uploaded foreground picture within the same cell. Code: <select name=ADDITIONALINFO> <option value="25 x 25">25 x 25</option> <option value="35 x 35">35 x 35</option> <option value="45 x 45">45 x 45</option> <option value="55 x 55">55 x 55</option> </select> Any guidance how to achieve this is appreciated. Hi I'm new to javascript, so this is probably very simple. I've created a form with combobox with different values (this is for my website). What I want is when the user clicks 'submit' that it goes to a different page on the website depending on the value the person has selected in the combobox. Values are numerical, for example 1000, 2000, 5000 etc. I've been trying this for a couple of days now without success! Thanks in advance I have rough ideas on how to achieve this but I dont know how to start. I want to use a drop-down menu selection option to submit a form. But the form's contents change depending on the option. This is the basic form: Code: <FORM ID="go1" METHOD="POST" TARGET="_self"> <INPUT TYPE=HIDDEN NAME=UserID VALUE="<%UserID%>"> <INPUT TYPE=HIDDEN NAME=Password VALUE="<%Password%>"> <INPUT TYPE=HIDDEN NAME=SubUnitID VALUE="4266"> <INPUT TYPE=HIDDEN NAME=PageID VALUE="1"> <INPUT TYPE="IMAGE" class="hand" border="0" src="/images/my.gif" width="45" height="26" vspace="5"> </FORM> At the moment, it's an image which gets clicked on but it needs to be the option chosen. I think I can do that with: Code: function gotoPage(s){ var v = s.selectedIndex; var select = document.forms.form.elements.input; // selects question if (v == 1){...} if (v == 2){...} etc. However, as I said, the form's contents must change depending on the option chosen: The form's values which change a Code: <INPUT TYPE=HIDDEN NAME=SubUnitID VALUE="4266"> <INPUT TYPE=HIDDEN NAME=PageID VALUE="1"> Can someone point me in the right direction? Hi Everyone, I'm encountering errors with a form I have created. I feel confident that the issue is with my JS validation form because when I allow the form to submit without validating any of the fields, my php processor correctly uploads all the content into my database (but, I will need the form validation to prevent the user from skipping fields). The issue (I believe) is with IE. In IE, both drop-downs seem to populate correctly but when I submit the form, I get a prompt to make a selection for the first drop-down menu. The form does submit properly in FireFox and Safari but with some testing I noticed that I was getting a prompt to make a selection in the first drop-down in instances where a selection was already made but I just had not yet populated the second country/state drop-down. Still, in Firefox and Safari, the form does pass validation upon submit.. So, I am hoping it's just IE specific issue. I'm thinking the issue is with IE not recognizing my selection. The form had a drop-down menu where the user selects a letter, then that selection triggers (in JS using a function to process the selection) another drop-down to populate with all the countries or states that begin with the letter from the first selection. Here is the code from my form: Code: <p><span class="title">Sign Up</span></p> <br /> <form id = "signupForm" action="signup_process.php" method = "post" onsubmit="return validateSignupForm();"> <p>All required fields are marked with ( <span class = "requiredStar">*</span> )</p> <br /> <p><label for="first_name">First Name: <span class = "requiredStar">*</span></label></p> <div class = "contactRight"><input type="text" name="first_name" id="first_name" style="height: 20px;" size="30" tabindex="1" maxlength="30" /></div> <br /> <p><label for="last_name">Last Name: <span class = "requiredStar">*</span></label></p> <div class = "contactRight"><input type="text" name="last_name" id="last_name" style="height: 20px;" size="30" tabindex="2" maxlength="30" /></div> <br /> <p><label for="countryLtr">Select the first letter of your country: <span class = "requiredStar">*</span></label></p> <select id="countryLtr" name="countryLtr" id="countryLtr" size="1" tabindex="3" onchange="processSelection()"> <option value=""></option> <option value="USA">USA</option> <option value="A">A</option> <option value="B">B</option> <option value="C">C</option> <option value="D">D</option> <option value="E">E</option> <option value="F">F</option> <option value="G">G</option> <option value="H">H</option> <option value="I">I</option> <option value="J">J</option> <option value="K">K</option> <option value="L">L</option> <option value="M">M</option> <option value="N">N</option> <option value="O">O</option> <option value="P">P</option> <option value="Q">Q</option> <option value="R">R</option> <option value="S">S</option> <option value="T">T</option> <option value="U">U</option> <option value="V">V</option> <option value="W">W</option> <option value="Y">Y</option> <option value="Z">Z</option> </select> <br /> <br /> <p><label for="countryState">Select your country/ state (if USA): <span class = "requiredStar">*</span></label></p> <select id="countryState" name="countryState" id="countryState" size="1" tabindex="4"> </select> <br /> <br /> <p><label for="username">Create a username: <span class = "requiredStar">*</span></label></p> <div class = "contactRight"><input type="text" name="username" id="username" style="height: 20px;" size="30" tabindex="5" maxlength="30" /></div> <br /> <p><label for="email">Email: <span class = "requiredStar">*</span></label></p> <div class = "contactRight"><input type="text" name="email" id="email" style="height: 20px;" size="30" tabindex="6" maxlength="30" /></div> <br /> <p><label for="password">Create a password: <span class = "requiredStar">*</span></label></p> <div class = "contactRight"><input type="password" name="password" id="password" style="height: 20px;" size="30" tabindex="7" maxlength="30" /></div> <br /> <br /> <input type="hidden" name="source" value="12345"> <input type="image" name="submit" value="Submit" class="submitButton" src="images/submit-button.png" /> <input type="image" name="reset" value="Reset" class="resetButton" src="images/reset-button.png" /> <br /> </form> and here is the code for processing the selection of the first drop-down and populating the second drop-down (I reduced the number of options for the countries to save on characters for this post): Code: function processSelection() { choice1 = document.getElementById("countryLtr"); choice2 = document.getElementById("countryState"); choice2.length = 0; if (choice1.value == "USA") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("Alaska"); choice2[choice2.length] = new Option("American Samoa"); choice2[choice2.length] = new Option("Arizona"); choice2[choice2.length] = new Option("Arkansas"); choice2[choice2.length] = new Option("California"); choice2[choice2.length] = new Option("Colorado"); choice2[choice2.length] = new Option("Connecticut"); choice2[choice2.length] = new Option("Delaware"); choice2[choice2.length] = new Option("District of Columbia"); choice2[choice2.length] = new Option("Florida"); choice2[choice2.length] = new Option("Georgia"); choice2[choice2.length] = new Option("Guam"); choice2[choice2.length] = new Option("Hawaii"); choice2[choice2.length] = new Option("Idaho"); choice2[choice2.length] = new Option("Illinois"); choice2[choice2.length] = new Option("Indiana"); choice2[choice2.length] = new Option("Iowa"); choice2[choice2.length] = new Option("Kansas"); choice2[choice2.length] = new Option("Kentucky"); choice2[choice2.length] = new Option("Louisiana"); choice2[choice2.length] = new Option("Maine"); choice2[choice2.length] = new Option("Maryland"); choice2[choice2.length] = new Option("Massachusetts"); choice2[choice2.length] = new Option("Michigan"); choice2[choice2.length] = new Option("Minnesota"); choice2[choice2.length] = new Option("Mississippi"); choice2[choice2.length] = new Option("Missouri"); choice2[choice2.length] = new Option("Montana"); choice2[choice2.length] = new Option("Nebraska"); choice2[choice2.length] = new Option("Nevada"); choice2[choice2.length] = new Option("New Hampshire"); choice2[choice2.length] = new Option("New Jersey"); choice2[choice2.length] = new Option("New Mexico"); choice2[choice2.length] = new Option("New York"); choice2[choice2.length] = new Option("North Carolina"); choice2[choice2.length] = new Option("North Dakota"); choice2[choice2.length] = new Option("Northern Marianas Islands"); choice2[choice2.length] = new Option("Ohio"); choice2[choice2.length] = new Option("Oklahoma"); choice2[choice2.length] = new Option("Oregon"); choice2[choice2.length] = new Option("Pennsylvania"); choice2[choice2.length] = new Option("Puerto Rico"); choice2[choice2.length] = new Option("Rhode Island"); choice2[choice2.length] = new Option("South Carolina"); choice2[choice2.length] = new Option("South Dakota"); choice2[choice2.length] = new Option("Tennessee"); choice2[choice2.length] = new Option("Texas"); choice2[choice2.length] = new Option("Utah"); choice2[choice2.length] = new Option("Vermont"); choice2[choice2.length] = new Option("Virginia"); choice2[choice2.length] = new Option("Virgin Islands"); choice2[choice2.length] = new Option("Washington"); choice2[choice2.length] = new Option("West Virginia"); choice2[choice2.length] = new Option("Wisconsin"); choice2[choice2.length] = new Option("Wyoming"); } else if (choice1.value == "A") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("Azerbaijan"); } else if (choice1.value == "B") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("The Bahamas"); } else if (choice1.value == "C") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("Czech Republic"); } else if (choice1.value == "D") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("Denmark"); } else if (choice1.value == "E") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("Ecuador"); } else if (choice1.value == "G") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("Gabon"); } else if (choice1.value == "H") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("Haiti"); } else if (choice1.value == "I") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("Iceland"); } else if (choice1.value == "J") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("Jamaica"); } else if (choice1.value == "K") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("Kazakhstan"); } else if (choice1.value == "L") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("Laos"); } else if (choice1.value == "M") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("Macau"); } else if (choice1.value == "N") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("Namibia"); } else if (choice1.value == "O") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("Oman"); } else if (choice1.value == "P") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("Pakistan"); } else if (choice1.value == "Q") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("Qatar"); } else if (choice1.value == "R") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("Reunion"); } else if (choice1.value == "S") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("Saint Helena"); } else if (choice1.value == "T") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("Taiwan"); } else if (choice1.value == "U") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("Uganda"); } else if (choice1.value == "V") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("Vanuatu"); } else if (choice1.value == "W") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("Wake Island"); } else if (choice1.value == "Y") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("Yemen"); } else if (choice1.value == "Z") { choice2[choice2.length] = new Option(""); choice2[choice2.length] = new Option("Zambia"); } } Here is the code for validating the form upon submission: Code: function validateRequestForm() { var theForm = document.getElementById("requestForm"); //form reference var valid = true; //flag, must be true to proceed if (theForm.name.value == "") { alert ("Please enter a name"); valid = false; theForm.username.focus(); } else if (theForm.countryLtr.value == "") { alert ("Please select the first letter of your country"); valid = false; theForm.countryLtr.focus(); } else if (theForm.countryState.value == "") { alert ("Please select your country. If USA, please select your state"); valid = false; theForm.countryState.focus(); } else if (theForm.email.value == "") { alert ("Please enter your email address"); valid = false; theForm.email.focus(); } else if (theForm.title.value == "") { alert ("Please enter a title for your request"); valid = false; theForm.title.focus(); } else if (theForm.request.value == "") { alert ("Please enter your request"); valid = false; theForm.request.focus(); } if (valid == true) { alert ("Thank you for your prayer request. Your request has been submitted for review. Please check your account to see the status of your prayer request. You may also check recent requests to view your request after it has been posted."); return true; //submit form } else { return false; //form invalid } } I'm totally stumped as to what could be going on in IE that is not allowing the form to pass JS validation.. Any help would be greatly appreciated!! Thanks! What i mean is - If ive got a 100% width div, and a person set only his country and name (i want to display inline), if only 2 of them is set i want 1 to be floating left, and one right, BUT IF 3 ISSET (like Date of Birth) i want the CSS to change to margin left 30px to make a gap between each of them, and if 4 isset then 20px gap, and so on, (got 5 that can be displayed there). I guess you do it JS/JQUERY
|