JavaScript - Need Help With Submitting Forms
Similar TutorialsHello, I have 3 forms on one page each with their own submit button. I think it would be really helpful if all 3 could be submitted at the one time, with 1 button, and I think I'll prob need Javascript to do this. I want to submit the forms together, posting all the information to a php page that deals with it. Is this possible? I'm using php. Thanks, Nicky I wonder if someone can help me. I've recently put together a new web form. The form is validated using JavaScript - it shows real-time error messages when forms are left blank, and also prevents the form from being submitted if any of the input data is invalid. The problem I have is that if JavaScript is disabled, the form cannot be submitted. At the moment I am submitting the form using the following button Code: <input type="button" value="Next" onclick="submitForm(this.form);" id="button" /> The 'onclick' event runs the 'submitForm' function, which runs a final validation check and submits the form if everything checks out. If there is invalid data in the table, an alert box pops up which prevents the form from submitting. Unfortunately, if JavaScript is disabled, the 'Next' button does nothing, as it is relying on JS to submit the form. I have tried using <input type="submit"> as well as <button type="submit">. Both of these allow the form to be submitted if JS is disabled. Unfortunately, when JavaScript IS enabled, the validation gets bypassed - the alert box still shows up but once you click 'OK' the form gets processed anyway. Can anyone suggest a solution? I am planning to write server-side validation in PHP as a backup but would prefer it if my JavaScript validation would work in it's entirety and the PHP simply be in place as a last line of defence for when JS is disabled. Thanks! I have a simple form that works via a suggested results system (http://www.brandspankingnew.net/arch...uggest_v2.html) While in firefox the go button is greyed out and enter doesn't submit the form in IE pressing the enter key submits the form. Is there any way with a bit of javascript to stop IE from doing a form submission on enter but only for this form (since there are many more on the site) PHP Code: <form action="index.php" method="GET" name="qsform" id="qsform"><input type="hidden" name="p" id="p" value="compdetails" style="border:1px solid #000000;" /><input type="text" name="quicksearch" id="quicksearch" value="Find Company" style="border:1px solid #000000;" onFocus="clearText(this)" onBlur="clearText(this)" /><input type="hidden" name="cid" id="cid" value="" style="border:1px solid #000000;" /> <input type="submit" name="go" id="go" value="Go" disabled="true" /></form> I'm using the autofill forms plugin for firefox which can be found he https://addons.mozilla.org/en-US/firefox/addon/4775 I use it to automatically fill various web forms, duh. But I would like certain values to be chosend randomly from a list I create. I contacted the developer and he said the add on probably does not need a new feature because there is a 'dynamic tags' function to fill certain forms with dynamic values (e.g. the current time or date). He has given over the project to another developer and told me I probably would find a solution in a good javascript programming forum. So here I am! Can anyone help me with this? Basically, I just need a javascript code which chooses on item from an array randomly, I guess? I'm not a programmer myself, so any help would be greatly (!) appreciated. Thanks a lot in advance for any further guidance! Note: Here are sample dynamic tags from the plugin: <datetime> new Date().toLocaleString() <useragent> navigator.userAgent <langcode> navigator.language <resolution> screen.width+'x'+screen.height <clipboard> this.getClipboardText() Hi on my site http://bit.ly/dcnrbJ (user:demo, pass:demo) subscribe to newsletter form at the bottom of the page is not working on IE7, any idea what the problem could be? I also get a popup with some error when loading the page.
Hi Guys i have a form on the website http://www.wewilbuyyourcar.ie this is a html form that i need to validate and submit and then show a certain page. I think everything is working except for the js any ideas? This is my form!! Code: <div id="contact_form"> <form id="contact" action="process.php"> <fieldset> <TR><TD><TABLE BORDER="0" CELLPADDING="3" CELLSPACING="0" WIDTH="50%"> <FORM ACTION="" METHOD="post" name="sellcarform" onsubmit="" > <TR><TD CLASS="tableBlueBody" ALIGN="right">* <B>First Name</B></TD><TD CLASS="tableBlueBody" STYLE="border-right : 1px solid #CCCCCC;" ALIGN="left"><INPUT TYPE="Text" NAME="firstname" MAXLENGTH="150"></TD><TD CLASS="tableBlueBody" ALIGN="right">* <B>Last Name</B></TD><TD CLASS="tableBlueBody" ALIGN="center"><INPUT TYPE="Text" NAME="lastname" MAXLENGTH="150"></TD></TR> <TR><TD CLASS="tableBlueBody" ALIGN="right"><B>Address</B></TD><TD CLASS="tableBlueBody" STYLE="border-right : 1px solid #CCCCCC;" ALIGN="left"><INPUT TYPE="Text" NAME="AddressLine1" MAXLENGTH="150"></TD><TD CLASS="tableBlueBody" ALIGN="right">* <B>Email</B></TD><TD CLASS="tableBlueBody" ALIGN="center"><INPUT TYPE="Text" NAME="email" MAXLENGTH="150"></TD></TR> <TR><TD CLASS="tableBlueBody" ALIGN="right"><B>City</B></TD><TD CLASS="tableBlueBody" STYLE="border-right : 1px solid #CCCCCC;" ALIGN="left"><INPUT TYPE="Text" NAME="City" MAXLENGTH="150"></TD><TD CLASS="tableBlueBody" ALIGN="right">* <B>Phone</B></TD><TD CLASS="tableBlueBody" ALIGN="center"><INPUT TYPE="Text" NAME="phone" MAXLENGTH="150"></TD></TR> <TR><TD CLASS="tableBlueBody" ALIGN="right"><B>Country</B></TD><TD CLASS="tableBlueBody" STYLE="border-right : 1px solid #CCCCCC;" ALIGN="left"> <select name="CountryID"> <option value="1" >Albania</option> <option value="2" >Algeria</option> <option value="3" >American Samoa</option> etc... </select> </TD><TD CLASS="tableBlueBody" ALIGN="right"><B>Fax</B></TD><TD CLASS="tableBlueBody" ALIGN="center"><INPUT TYPE="Text" NAME="fax" MAXLENGTH="150"></TD></TR> <TR><TD COLSPAN="4" CLASS="tableBlueBody"> </TD></TR> <TR><TD CLASS="tableBlueBody" ALIGN="right" VALIGN="top"> <B>Comments</B> </TD><TD COLSPAN="3" CLASS="tableBlueBody" ALIGN="left"> <TEXTAREA NAME="comment" ROWS="7" COLS="45" ></TEXTAREA> </TD></TR> </TD><TD COLSPAN="5" CLASS="tableBlueBody" ALIGN="left"> <TR><TD CLASS="tableBlueBody" ALIGN="right">* <B>Registration Number</B></TD><TD CLASS="tableBlueBody" STYLE="border-right : 1px solid #CCCCCC;" ALIGN="left"><INPUT TYPE="Text" NAME="regnumber" MAXLENGTH="150"></TD><TD CLASS="tableBlueBody" ALIGN="right">* <B>Colour</B></TD><TD CLASS="tableBlueBody" ALIGN="center"><INPUT TYPE="Text" NAME="colour" MAXLENGTH="150"></TD></TR> <TR><TD CLASS="tableBlueBody" ALIGN="right">* <B>Car Make</B></TD><TD CLASS="tableBlueBody" STYLE="border-right : 1px solid #CCCCCC;" ALIGN="left"><INPUT TYPE="Text" NAME="carmake" MAXLENGTH="150"></TD><TD CLASS="tableBlueBody" ALIGN="right">* <B>Has the vehicle been used as a taxi?</B></TD><TD CLASS="tableBlueBody" ALIGN="center"><input type='radio' value="Yes" name='question1' /> Yes <input name='question1' type="radio" value="No" checked /> No</TD></TR> <TR><TD CLASS="tableBlueBody" ALIGN="right">* <B>Model</B></TD><TD CLASS="tableBlueBody" STYLE="border-right : 1px solid #CCCCCC;" ALIGN="left"><INPUT TYPE="Text" NAME="model" MAXLENGTH="150"></TD><TD CLASS="tableBlueBody" ALIGN="right">* <B>Is finance outstanding on the vehicle?</B></TD><TD CLASS="tableBlueBody" ALIGN="center"><input type='radio' value="Yes" name='question2' /> Yes <input name='question2' type="radio" value="No" checked /> No</TD></TR> <TR><TD CLASS="tableBlueBody" ALIGN="right">* <B>Milage / Kms</B></TD><TD CLASS="tableBlueBody" STYLE="border-right : 1px solid #CCCCCC;" ALIGN="left"><INPUT TYPE="Text" NAME="milage" MAXLENGTH="150"></TD><TD CLASS="tableBlueBody" ALIGN="right">* <B>How did you hear about us?</B></TD><TD CLASS="tableBlueBody" ALIGN="center"><select name="question3"><option value="Other">Other</option><option value="Web">Web</option><option value="Newspaper">Newspaper</option><option value="Radio">Radio</option><option value="Recommended">Recommended</option></select></TD></TR> <TR><TD COLSPAN="2" CLASS="tableBlueBody" STYLE="border-bottom : 1px solid #CCCCCC; border-right : 1px solid #CCCCCC;"> </TD><TD COLSPAN="2" CLASS="tableBlueBody" STYLE="border-bottom : 1px solid #CCCCCC;"> </TD></TR> <TR><TD COLSPAN="4" ALIGN="left"><input type="submit" value="Click here to send us your information" class='contactFormSubmit'></TD></TR> </FORM></TABLE> </TD></TR></TABLE><BR></TD> <TD><IMG SRC="images/spacer.gif" WIDTH="8" HEIGHT="1" BORDER="0" ALT=""></TD> <TD WIDTH="183" VALIGN="top"> </TD></TR></TABLE> </fieldset> </form><br /> </div><!-- end of #contact_form --> This is my process.php file!! PHP Code: <?php $emailTo = 'sakura-designs@hotmail.com'; $subject = 'We Will Buy Your Car.ie Form Submission'; $firstname=$_POST['firstname']; $lastname=$_POST['lastname']; $email=$_POST['email']; $AddressLine1=$_POST['AddressLine1']; $City=$_POST['City']; $phone=$_POST['phone']; $CountryID=$_POST['CountryID']; $fax=$_POST['fax']; $comment=$_POST['comment']; $regnumber=$_POST['regnumber']; $colour=$_POST['colour']; $carmake=$_POST['carmake']; $question1=$_POST['question1']; $model=$_POST['model']; $question2=$_POST['question2']; $milage=$_POST['milage']; $question3=$_POST['question3']; $body = "First Name: $firstname \n\nLast Name: $lastname \n\nEmail: $email \n\nAddress: $AddressLine1 \n\nCity: $city \n\nPhone: $phone \n\nCountry: $CountryID \n\nFax: $fax \n\nComment: $comment \n\nReg Number: $regnumber \n\nColour: $colour \n\nCar Make: $carmake \n\nQuestion1: $question1 \n\nModel: $model \n\nQuestion2: $question2 \n\nMilage: $milage \n\nQuestion3: $question3"; $headers = 'From: '.$name.' <'.$email.'>' . "\r\n" . 'Reply-To: ' . $email; mail($emailTo, $subject, $body); header( "Location: http://www.wewillbuyyourcar.ie/thankyou.html" ); ?> And this is my contact1.js file!! Code: $(document).ready( function() { $('.error').hide(); $('.but').click( function() { var fname = document.getElementById('firstname'); var lname = document.getElementById('lastname'); var email = document.getElementById('email'); var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; var AddressLine1 = document.getElementById('AddressLin1'); var city = document.getElementById('city'); var phone = document.getElementById('phone'); var CountryID = document.getElementById('CountryID'); var fax = document.getElementById('fax'); var comment = document.getElementById('comment'); var regnumber = document.getElementById('regnumber'); var colour = document.getElementById('colour'); var carmake = document.getElementById('carmake'); var question1 = document.getElementById('question1'); var model = document.getElementById('model'); var question2 = document.getElementById('question2'); var milage = document.getElementById('milage'); var question3 = document.getElementById('question3'); if(fname.val() != '' && lname.val() != '') { if(email.val() != '' && emailReg.match.exp) { if(comment != '') { $('#comment_error').show(); comment.focus(); return false; } else { var dataString = 'name='+ fname + lname +'&email=' + email + '&comment=' + comment; //alert (dataString);return false; $ajax({ type: "POST", url: "process.php", data: dataString, success: function() { $('#contact_form').html("<div id='message'></div>"); $('#message').html("<strong>Contact Form Submitted!</strong>") .append("<p>We will be in touch soon.</p>") .hide() .fadeIn(1500, function() { jQuery('#message'); }); } }); } } else { $('#email_error').show(); email.focus(); return false; } } else { $('#name_error').show(); fname.focus(); return false; } }); }); Thanks for all your help in advance and Merry Christmas I am trying to submit a hidden text area from a WYSIWYG editor. Its submitting the subject line which is a standard text input but its not submitting the text area. I can only think its because there are html tags in the submitted data. Is there a way to compensate for this or will I have to give up trying. Anyone know how to submit a form and when I press submit, it should simulating the submission of another form, for example let's say Form A, and when I press submit button and submit Form A, it should also automatically submit Form B. Anyone pls help, thanks I have a problem when submitting through javascript, i have used it hundred times, but i dont know why it refuses to work now, http://two.xthost.info/shailesh/test.htm Please look at the attached file in IE 6 and when you click on "Delete Selected" button, you get javascript error and the form refuses to submit the error is on line document.myform.submit(); I am having trouble submitting a form after validation. Here is my script. The validation works fine its just that after the form does not submit. Code: <script language='javascript'> function verifyMe(){ var msg=''; if(document.getElementById('company').value==''){ msg+='- Company Name\n\n';} if(document.getElementById('contact').value==''){ msg+='- Contact Name / Job Title\n\n';} if(document.getElementById('address').value==''){ msg+='- Trading Address\n\n';} if(document.getElementById('postcode').value==''){ msg+='- Postcode\n\n';} if(document.getElementById('telephone').value==''){ msg+='- Telephone\n\n';} if(document.getElementById('mobile').value==''){ msg+='- Mobile\n\n';} var email=document.getElementById('email').value; if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))){ msg+='- Invalid Email Address: '+email+'\n\n';} if(document.getElementById('email').value==''){ msg+='- Email\n\n';} if(document.getElementById('employees').value==''){ msg+='- Number of Full-Time equivalent employees\n\n';} if(document.getElementById('turnover').value==''){ msg+='- Annual Turnover\n\n';} if(document.getElementById('assetvalue').value==''){ msg+='- Total asset value\n\n';} if(!document.getElementById('sme[0]').checked && !document.getElementById('sme[1]').checked){ msg+='- Is more than 25% of your company owned by an enterprise which is not itself an SME?\n\n';} if(document.getElementById('tradetime').value==''){ msg+='- How many months has your company been trading?\n\n';} if(document.getElementById('nature').value==''){ msg+='- Nature of Business Sector\n\n';} if(document.getElementById('typeofo').value==''){ msg+='- Type of Organisation\n\n';} if(document.getElementById('companyregisteredname').value==''){ msg+='- Company Registered Name\n\n';} if(document.getElementById('regnumber').value==''){ msg+='- Registration Number\n\n';} if(document.getElementById('vatreg').value==''){ msg+='- VAT Reg Number\n\n';} if(document.getElementById('regaddress').value==''){ msg+='- Registered Address\n\n';} if(document.getElementById('catapply').value==''){ msg+='- Which Catagories Apply?\n\n';} if(document.getElementById('fuelused').value==''){ msg+='- Current fuel used\n\n';} if(document.getElementById('otherfuel').value==''){ msg+='- Other (if applicable)\n\n';} if(document.getElementById('heatingpercent').value==''){ msg+='- What percentage of this is used for heating?\n\n';} if(document.getElementById('factoryspaceheating').value==''){ msg+='- Factory Space Heating\n\n';} if(document.getElementById('officeheating').value==''){ msg+='- Office Heating\n\n';} if(document.getElementById('hotwater').value==''){ msg+='- Hot Water\n\n';} if(document.getElementById('heaterrating').value==''){ msg+='- Combine Rating of Existing Heaters\n\n';} if(document.getElementById('existingheaters').value==''){ msg+='- Number of existing heaters\n\n';} if(document.getElementById('setbackheating').value==''){ msg+='- Is night set back heating employed?\n\n';} if(document.getElementById('billavalable').value==''){ msg+='- Are they avalable?\n\n';} if(document.getElementById('factorysize').value==''){ msg+='- Factory Size\n\n';} if(document.getElementById('roofheighte').value==''){ msg+='- Roof Height to Eaves\n\n';} if(document.getElementById('roofheightr').value==''){ msg+='- Roof Height to Ridge\n\n';} if(document.getElementById('builddate').value==''){ msg+='- Approx. Date building was built\n\n';} if(document.getElementById('spraybooths').value==''){ msg+='- Spray Booths?\n\n';} if(document.getElementById('dustextract').value==''){ msg+='- Dust Extraction\n\n';} if(document.getElementById('air').value==''){ msg+='- Is the air returned to the building?\n\n';} if(document.getElementById('rollershutters').value==''){ msg+='- Roller Shutters?\n\n';} if(document.getElementById('weekoc').value==''){ msg+='- Weekly building occupancy\n\n';} if(document.getElementById('occupancy').value==''){ msg+='- Daily Building Occupancy\n\n';} if(document.getElementById('woodwaste').value==''){ msg+='- Type of wood waste\n\n';} if(document.getElementById('woodavailable').value==''){ msg+='- Quantity available per wek\n\n';} if(document.getElementById('upload').value==''){ msg+='- Upload bills here.\n\n';} if(msg!=''){ alert('The following fields are empty or invalid:\n\n'+msg); return false }else{ document.carbonform.submit(); return true } } </script> <html> <head> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="stylized" class="myform"> <form name='carbonform' action="process.php" method='POST' enctype='application/x-www-form-urlencoded' onsubmit='return verifyMe();'> <table class='table_form_1' id='table_form_1' cellspacing='0'> <h1>Carbon Trust Application Form.</h1> <p>Please make sure you enter all fields marked with an <b style='color:red'>*</b>. If you submit an incomplete form we cannot help you.</p> <tr> <td class='ftbl_row_1' ><LABEL for='company' ACCESSKEY='none' ><b style='color:red'>*</b>Company Name </td> <td class='ftbl_row_1a' ><input type='text' name='company' id='company' size='45' maxlength='150' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='contact' ACCESSKEY='none' ><b style='color:red'>*</b>Contact Name / Job Title </td> <td class='ftbl_row_2a' ><input type='text' name='contact' id='contact' size='45' maxlength='150' value=''> </td> </tr> <tr> <td valign='top' class='ftbl_row_1' ><LABEL for='address' ACCESSKEY='none' ><b style='color:red'>*</b>Trading Address </td> <td class='ftbl_row_1a' ><textarea name='address' id='address' cols='35' rows='6' value=''></textarea> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='postcode' ACCESSKEY='none' ><b style='color:red'>*</b>Postcode </td> <td class='ftbl_row_2a' ><input type='text' name='postcode' id='postcode' size='45' maxlength='10' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='telephone' ACCESSKEY='none' ><b style='color:red'>*</b>Telephone </td> <td class='ftbl_row_1a' ><input type='text' name='telephone' id='telephone' size='45' maxlength='30' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='mobile' ACCESSKEY='none' ><b style='color:red'>*</b>Mobile </td> <td class='ftbl_row_2a' ><input type='text' name='mobile' id='mobile' size='45' maxlength='20' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='email' ACCESSKEY='none' ><b style='color:red'>*</b>Email </td> <td class='ftbl_row_1a' ><input type='text' name='email' id='email' size='45' maxlength='50' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='employees' ACCESSKEY='none' ><b style='color:red'>*</b>Number of Full-Time equivalent employees </td> <td class='ftbl_row_2a' ><input type='text' name='employees' id='employees' size='45' maxlength='8' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='turnover' ACCESSKEY='none' ><b style='color:red'>*</b>Annual Turnover </td> <td class='ftbl_row_1a' ><input type='text' name='turnover' id='turnover' size='45' maxlength='20' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='assetvalue' ACCESSKEY='none' ><b style='color:red'>*</b>Total asset value </td> <td class='ftbl_row_2a' ><input type='text' name='assetvalue' id='assetvalue' size='45' maxlength='20' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><b style='color:red'>*</b>Is more than 25% of your company owned by an enterprise which is not itself an SME? </td> <td class='ftbl_row_1a' > <LABEL ACCESSKEY='1'><input type='checkbox' name='sme' id='sme[0]' value='Yes'>Yes</LABEL> <LABEL ACCESSKEY='2'><input type='checkbox' name='sme' id='sme[1]' value='No' CHECKED >No</LABEL> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='tradetime' ACCESSKEY='none' ><b style='color:red'>*</b>How many months has your company been trading? </td> <td class='ftbl_row_2a' ><input type='text' name='tradetime' id='tradetime' size='45' maxlength='5' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='nature' ACCESSKEY='none' ><b style='color:red'>*</b>Nature of Business Sector </td> <td class='ftbl_row_1a' ><input type='text' name='nature' id='nature' size='45' maxlength='50' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='typeofo' ACCESSKEY='none' ><b style='color:red'>*</b>Type of Organisation </td> <td class='ftbl_row_2a' ><select name='typeofo' id='typeofo'> <option value='Public'>Public</option> <option value='Private'>Private</option> <option value='Charity'>Charity</option> <option value='Limited / Sole Trader'>Limited / Sole Trader</option> </select> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='companyregisteredname' ACCESSKEY='none' ><b style='color:red'>*</b>Company Registered Name </td> <td class='ftbl_row_1a' ><input type='text' name='companyregisteredname' id='companyregisteredname' size='45' maxlength='150' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='regnumber' ACCESSKEY='none' ><b style='color:red'>*</b>Registration Number </td> <td class='ftbl_row_2a' ><input type='text' name='regnumber' id='regnumber' size='45' maxlength='10' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='vatreg' ACCESSKEY='none' ><b style='color:red'>*</b>VAT Reg Number </td> <td class='ftbl_row_1a' ><input type='text' name='vatreg' id='vatreg' size='45' maxlength='15' value=''> </td> </tr> <tr> <td valign='top' class='ftbl_row_2' ><LABEL for='regaddress' ACCESSKEY='none' ><b style='color:red'>*</b>Registered Address </td> <td class='ftbl_row_2a' ><textarea name='regaddress' id='regaddress' cols='35' rows='6' value=''></textarea> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='catapply' ACCESSKEY='none' ><b style='color:red'>*</b>Which Catagories Apply? </td> <td class='ftbl_row_1a' ><select name='catapply' id='catapply'> <option value='Space Heating'>Space Heating</option> <option value=' Process Heating'> Process Heating</option> </select> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='fuelused' ACCESSKEY='none' ><b style='color:red'>*</b>Current fuel used </td> <td class='ftbl_row_2a' ><select name='fuelused' id='fuelused'> <option value='Gas'>Gas</option> <option value='Oil'>Oil</option> <option value='Other'>Other</option> </select> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='otherfuel' ACCESSKEY='none' ><b style='color:red'>*</b>Other (if applicable) </td> <td class='ftbl_row_1a' ><input type='text' name='otherfuel' id='otherfuel' size='45' maxlength='30' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='heatingpercent' ACCESSKEY='none' ><b style='color:red'>*</b>What percentage of this is used for heating? </td> <td class='ftbl_row_2a' ><input type='text' name='heatingpercent' id='heatingpercent' size='45' maxlength='3' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='factoryspaceheating' ACCESSKEY='none' ><b style='color:red'>*</b>Factory Space Heating </td> <td class='ftbl_row_1a' ><input type='text' name='factoryspaceheating' id='factoryspaceheating' size='45' maxlength='100' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='officeheating' ACCESSKEY='none' ><b style='color:red'>*</b>Office Heating </td> <td class='ftbl_row_2a' ><input type='text' name='officeheating' id='officeheating' size='45' maxlength='3' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='hotwater' ACCESSKEY='none' ><b style='color:red'>*</b>Hot Water </td> <td class='ftbl_row_1a' ><input type='text' name='hotwater' id='hotwater' size='45' maxlength='3' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='heaterrating' ACCESSKEY='none' ><b style='color:red'>*</b>Combine Rating of Existing Heaters </td> <td class='ftbl_row_2a' ><input type='text' name='heaterrating' id='heaterrating' size='45' maxlength='10' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='existingheaters' ACCESSKEY='none' ><b style='color:red'>*</b>Number of existing heaters </td> <td class='ftbl_row_1a' ><input type='text' name='existingheaters' id='existingheaters' size='45' maxlength='4' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='setbackheating' ACCESSKEY='none' ><b style='color:red'>*</b>Is night set back heating employed? </td> <td class='ftbl_row_2a' ><select name='setbackheating' id='setbackheating'> <option value='Yes'>Yes</option> <option value='No'>No</option> </select> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='billavalable' ACCESSKEY='none' ><b style='color:red'>*</b>Are they avalable? </td> <td class='ftbl_row_1a' ><select name='billavalable' id='billavalable'> <option value='Yes'>Yes</option> <option value='No'>No</option> </select> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='factorysize' ACCESSKEY='none' ><b style='color:red'>*</b>Factory Size </td> <td class='ftbl_row_2a' ><input type='text' name='factorysize' id='factorysize' size='45' maxlength='60' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='roofheighte' ACCESSKEY='none' ><b style='color:red'>*</b>Roof Height to Eaves </td> <td class='ftbl_row_1a' ><input type='text' name='roofheighte' id='roofheighte' size='45' maxlength='10' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='roofheightr' ACCESSKEY='none' ><b style='color:red'>*</b>Roof Height to Ridge </td> <td class='ftbl_row_2a' ><input type='text' name='roofheightr' id='roofheightr' size='45' maxlength='10' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='builddate' ACCESSKEY='none' ><b style='color:red'>*</b>Approx. Date building was built </td> <td class='ftbl_row_1a' ><input type='text' name='builddate' id='builddate' size='45' maxlength='10' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='spraybooths' ACCESSKEY='none' ><b style='color:red'>*</b>Spray Booths? </td> <td class='ftbl_row_2a' ><select name='spraybooths' id='spraybooths'> <option value='Yes'>Yes</option> <option value='No'>No</option> </select> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='dustextract' ACCESSKEY='none' ><b style='color:red'>*</b>Dust Extraction </td> <td class='ftbl_row_1a' ><select name='dustextract' id='dustextract'> <option value='Yes'>Yes</option> <option value='No'>No</option> </select> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='air' ACCESSKEY='none' ><b style='color:red'>*</b>Is the air returned to the building? </td> <td class='ftbl_row_2a' ><select name='air' id='air'> <option value='Yes'>Yes</option> <option value='No'>No</option> </select> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='rollershutters' ACCESSKEY='none' ><b style='color:red'>*</b>Roller Shutters? </td> <td class='ftbl_row_1a' ><select name='rollershutters' id='rollershutters'> <option value='Yes'>Yes</option> <option value='No'>No</option> </select> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='weekoc' ACCESSKEY='none' ><b style='color:red'>*</b>Weekly building occupancy </td> <td class='ftbl_row_2a' ><input type='text' name='weekoc' id='weekoc' size='45' maxlength='10' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='occupancy' ACCESSKEY='none' ><b style='color:red'>*</b>Daily Building Occupancy </td> <td class='ftbl_row_1a' ><input type='text' name='occupancy' id='occupancy' size='45' maxlength='5' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='woodwaste' ACCESSKEY='none' ><b style='color:red'>*</b>Type of wood waste </td> <td class='ftbl_row_2a' ><input type='text' name='woodwaste' id='woodwaste' size='45' maxlength='30' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='woodavailable' ACCESSKEY='none' ><b style='color:red'>*</b>Quantity available per wek </td> <td class='ftbl_row_1a' ><input type='text' name='woodavailable' id='woodavailable' size='45' maxlength='20' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='upload' ACCESSKEY='none' ><b style='color:red'>*</b>Upload bills here. </td> <td class='ftbl_row_2a' ><input type='file' name='upload' id='upload' size='100' value=''> </td> </tr> <tr> <td colspan='2' align='right'><input type='submit' name='submit' value='Submit' onclick="function verifyMe()" > <input type='reset' name='reset' value='Reset'><br /><a href='http://www.Jaynetdesign.com.com' style='font-family:arial;font-size:10px;color:#C0C0C0;text-decoration:none'>Created by James Eley</a> </td> </tr> </table> </form> </div> </body> </HTML> Key info is on lines: 138 - 152 Code: if(msg!=''){ alert('The following fields are empty or invalid:\n\n'+msg); return false }else{ document.carbonform.submit(); return true } } Code: <form name='carbonform' action="process.php" method='POST' enctype='application/x-www-form-urlencoded' onsubmit='return verifyMe();'> and 441. Code: <td colspan='2' align='right'><input type='submit' name='submit' value='Submit' onclick="function verifyMe()" > <input type='reset' name='reset' value='Reset'> My php script just contains an echo to test. Thanks in advance. Can anyone tell why IE does not handle this form submit properly? Instead of going to the action of the form in formString, it just refreshes the page. Works fine in Firefox and Chrome. Code: Here is how the form is placed on the page and then submitted: document.getElementById('crtDiv').innerHTML = formString; document.getElementById('crtForm').submit(); Here is an example of how the formString is built: formString = "<form action='https://www.paypal.com/cgi-bin/webscr' method='POST' id='crtForm'>"; formString += BUNCH O INPUTS formString += "</form>"; Hello! I was wondering if it is possible with Javascript to keep the values of certain variables in memory, even if another page has been loaded. My aim is to gather information from a few pages and, when come to the last page, submit them all together to the perl script. My first page looks like: Code: <form name="step1" method="post" action="/cgi-sys/formmail.pl"> <input type="hidden" name="recipient" value="pavlos.thes@gmail.com"/> <input type="hidden" name="subject" value="Poll Results"/> <input name="radiobutton" type="radio" value="Grill"> Grill <input name="radiobutton" type="radio" value="Club"> Club Sandwich <input name="radiobutton" type="radio" value="Crepes"> Crepes <input name="radiobutton" type="radio" value="Toast"> Toast <input name="radiobutton" type="radio" value="Hotdog"> Hot Dog <input name="radiobutton" type="radio" value="Special"> Special Products <input name="radiobutton" type="radio" value="Salads"> Salads <p> <input type="button" name="Submit" value="Next Question >" onclick="javascript:location.href='Poll_Jan2010_02.html'"> </form> And the next ones look pretty much the same, only the name of the form changes (step2, step3, step4 etc), and the url of the location.href in the end (Poll_Jan2010_03.html, Poll_Jan2010_04.html, etc) and of course in the next pages i might use checkboxes or textfields instead of radiobuttons. Could someone help me out doing this? Hello, I have been trying to get my html form to submit to a php pop up window so that I can use the user entered data there... so far with little to no success. Here is my current code - Index.html Code: <script> function popup() { win = window.open('','myWin','toolbars=0'); document.post.action='popup.php'; document.post.rel="nofollow" target='myWin'; document.post.submit(); } </script> <div align="center"> <form name="post" action="popup.php" method="post" rel="nofollow" target="_self"> <input type="text" size="85" style="text-align: center" name="txttesturl" /> <br> <input type="button" name="post" class="submit" Value="Pop up" onclick"popup(); " /> </div> </form> popup.php Code: <?php $Testurl = $_POST["txttesturl"]; //Various bits of code ?> Any help would be greatly appreciated, as it stands I am getting NO response from the button. Edit - Nevermind..... I was missing an equals sign in the form ... HI I have a form that has some fields and inputs . I wrote some javascript code that if there was any problem with entered values , it shows the errors but when the user press submit button , the form submited before it had shown the problems . How can halt it and showing the problems ? TNX hello .. i have some problem while while working on a script.. i want to use confirmation() function to confirm submit button and if its true ...then submit form... else keep on same page (thats logic) am using php as server scripting .. and i wrote ..in php PHP Code: <form action="del_cat.php\" name=\"myform\" method=\"post\"> "; Delete: <input type="submit\" name=\"delete\" onclick=\"confirmation()\" value=\"Delete\" > <br> Edit:<input type=\"submit\" name=\"edit\" value=\"Edit\" > </form>"; and used a javascript in head PHP Code: <script type="text/javascript\"> function confirmation() { var r=confirm(\"Are you ready to delete?\"); if (r==true) { document.myform.submit(); } else { alert(\"check twise before submitting \") } } </script> my problem is if i click "OK" or "Cancel" both case the form is automatically submitting ... see i used PHP Code: if (isset($_POST['delete'])) { mysql_query("DELETE FROM ********* WHERE id='{$_POST['cid']}'"); } this code to invoke the function .. The thing i want to do If any field is empty -->User will see a message to fill out the field When both field is filled out and press Submit button --> goes to thankyou.php page <html> <head></head> <body> <?php $fname = $_POST['fname']; $lname = $_POST['lname']; ?> <form action="thankyou.php" method="POST"> First Name: <input type="text" name='fname'/> <?php if(empty($fname)) echo "Please provide your First Name";?><br/> Last Name: <input type="text" name='lname'/> <?php if(empty($lname)) echo "Please provide your Last Name";?><br/> <input type="submit" value="submit" /><input type="reset" value="Clear Form"/> </form> </body> </html> thankyou.php <?php echo "Thank you $fname $lname for your time." ?> Hi there, I am trying to automatically submit a form in an iframe with javascript. My question is whether this is possible or not, and if so how the code should look like to submit the form in the iframe? this is the form within the iframe that I am trying to submit automatically: Code: <form id="Form2051051" action="nieuw-bericht.2051051.lynkx" method="post" class="form" onsubmit="return ProcessForm( 'Form2051051' );"> <div> <a href="#" onclick="document.getElementById( 'event' ).value='Step1'; document.getElementById( 'Form2051051' ).submit(); return false;" class="button previous"><span>Wijzig</span></a> <a href="#" onclick="if ( ProcessForm( 'Form2051051' ) ) document.getElementById( 'Form2051051' ).submit(); return false;" class="button next-long"><span>Plaats bericht</span></a> </div> <input type="hidden" id="event" name="event" value="Confirmed-Step3" /> <input type="hidden" name="PostedField[_berichtId]" value="" /> <input type="hidden" name="formState" value="KQAAAAoAAAEAAgADAAQABQA9taWULZGFzZGFzIHNhZGEA" /> </form> this is what I have tried so far: Code: <body LANGUAGE="javascript" onload="window.frames['myframe'].document.getElementById( 'Form2051051' ).submit();"> <iframe name="myframe" id="frame1" src="link-to-the-page-with-the-form"> </iframe> </body> It might be worth to mention that the webpage within the iframe is from an external website (im not in control of it). I am not sure if it's possible to use javascript on an external website in an iframe? I am pretty new with this so I appreciate any help or suggestions! thank you I am tired and fatigued, but I don't believe enough to not find obvious mistakes. I'm having a very strange issue that I have not encounted where a HTML form is submitting when just the first two INPUT's are filled in, but it shouldn't be able to submit because there are still other INPUT boxes that are empty and required to be filled for JavaScript to allow the form to submit. Can anyone see what the problem is? Code: <SCRIPT type="text/javascript"> function validateForm() { if (document.forms["form"]["cardholdername"].value=="") { alert ("Cannot proceed to purchase because a Visa card name has not been specified."); return false; } if (document.forms["form"]["cardnumber"].value=="") { alert ("Cannot proceed to purchase because a Visa card number has not been specified."); return false; } if (document.forms["form"]["cardexpirymonth"].value=="") { alert ("Cannot proceed to purchase because a Visa card expiry month has not been selected."); return false; } if (document.forms["form"]["cardexpiryyear"].value=="") { alert ("Cannot proceed to purchase because a Visa card expiry year has not been selected."); return false; } if (document.forms["form"]["cardcvv"].value=="") { alert ("Cannot proceed to purchase because a Visa card CVV has not been specified."); return false; } if (document.forms["form"]["cardholdere-mailaddress"].value=="") { alert ("Cannot proceed to purchase because a Visa card holder e-mail address has not been specified."); return false; } if (document.forms["form"]["cardholdercontactnumber"].value=="") { alert ("Cannot proceed to purchase because a Visa card holder contact number has not been specified."); return false; } } </SCRIPT> Code: <FORM action="processpaymentinformation.html" method="post" name="form" onsubmit="return validateForm()"> <DIV class="payment"> <DIV class="visacard"><B>Visa card:</B></DIV> <BR> <DIV class="cardholdername"><B>Name:</B> <INPUT name="cardholdername" type="text"></DIV> <DIV class="cardnumber"><B>Number:</B> <INPUT name="cardnumber" type="text"></DIV> <DIV class="cardexpirymonth"><B>Expiry month:</B> <SELECT name="cardexpirymonth"> <OPTION></OPTION> <OPTION>01</OPTION> <OPTION>02</OPTION> <OPTION>03</OPTION> <OPTION>04</OPTION> <OPTION>05</OPTION> <OPTION>06</OPTION> <OPTION>07</OPTION> <OPTION>08</OPTION> <OPTION>09</OPTION> <OPTION>10</OPTION> <OPTION>11</OPTION> <OPTION>12</OPTION> </SELECT> </DIV> <DIV class="cardexpiryyear"><B>Expiry year:</B> <SELECT name="cardexpirymonth"> <OPTION></OPTION> <OPTION>13</OPTION> <OPTION>14</OPTION> <OPTION>15</OPTION> <OPTION>16</OPTION> <OPTION>17</OPTION> </SELECT> </DIV> <DIV class="cardcvv"><B>CVV:</B> <INPUT class="cardcvv" name="cardcvv" type="password"></DIV> <BR> <BR> <DIV class="visacardholder"><B>Visa card holder:</B></DIV> <BR> <DIV class="cardholdertitle"><B>Title:</B> <SELECT name="cardholdertitle"> <OPTION></OPTION> <OPTION>Dr</OPTION> <OPTION>Madam</OPTION> <OPTION>Miss</OPTION> <OPTION>Mr</OPTION> <OPTION>Mrs</OPTION> <OPTION>Ms</OPTION> <OPTION>Sir</OPTION> </SELECT> </DIV> <DIV class="cardholdere-mailaddress"><B>E-mail address:</B> <INPUT name="cardholdere-mailaddress" type="text"></DIV> <B>Contact number:</B> <INPUT name="cardholdercontactnumber" type="text"> </DIV> <DIV> <INPUT class="submit" type="submit" value="PROCEED TO PURCHASE"> </DIV> </FORM> I am not sure why this is happening, but the script is working and throwing an alert but still submits. Code: <script type="text/javascript"> function check(a,b) { var obja = document.getElementById('email') var objb = document.getElementById('confemail') if (obja.value==objb.value) {} else {alert("The e-mail fields aren't the same!!") } return false; } </script> Code: <table> <tr><td colspan="2">Email:</td></tr> <tr><td colspan="2"> <input type="text" name="email" class="wide" id="email"></td></tr> <tr><td colspan="2">Confirm Email:</td></tr> <tr><td colspan="2"> <input type="text" name="confemail" id="confemail" class="wide"></td></tr> <tr><td colspan="2"><br /> <input name="Submit" type="submit" value="Submit Help Request" onclick="check('email','confemail') "></td></tr> </table> does anyone see the issue? Thanks for any help. What line of javascript can I use to submit a form that's inside an iFrame? Here are a couple of failed attempts: Code: document.getElementById('captcha_iframe').forms['reserve_booth_space'].submit(); window.frames['captcha_iframe'].forms['reserve_booth_space'].submit(); |