JavaScript - Refresh Calculations Without Submitting Form
I want to refresh the calculations on a form without submitting the form. I have tried two different JavaScript button codes, and I'm wondering if there is a reason for using one over the other, and if there is something else better for cross-browser use.
1) [ICODE] _doClick('$Refresh', this, '_self') 2) [ICODE] _doClick('$Refresh', this, null, null) Sorry if I missed the answer to this by searching, but I did try. Advice is welcome. Similar TutorialsI 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. when i click on submit button, all the data in form will be inserted into my db. but when i click on refresh the form will be submitted again .. how can i prevent this?
This code does not want to add the text box to my calculations. I also tried to parseFloat() the tDelivery but then it gives a NaN, I also tried parseInt() same Nan then With the exact code below it encapsulates the two totals printing eg: R150 R35. All the other boxes works perfectly just the last one to add the delivery. Code: // Function to calculate order value function calculateValue(orders) { var orderValue = 0; // Run through all the product fields for(var i = 0; i < orders.elements.length; ++i) { // Get the current field var formField = orders.elements[i]; // Get the fields name var formName = formField.name; // Is it a "product" field? if (formName.substring(0,4) == "prod") { // Items price extracted from name var itemPrice = parseFloat(formName.substring(formName.lastIndexOf("_") + 1)); // Get the Quantity var itemQuantity = parseInt(formField.value); // Update the OrderValue if(itemQuantity >= 0) { orderValue += itemQuantity * itemPrice; } } } // Display the totals orders.totalExcl.value = "R " + orderValue.toLocaleString(); // function to calculate VAT at 15% as required and total inclusive. function calcTotals(oValue) { var vat = oValue * .15; var totalIncluding = oValue + vat; var tDelivery = orders.delivery.value; var theTotalOrder = totalIncluding + tDelivery; orders.vat.value = "R " + vat.toLocaleString(); orders.totalIncl.value = "R " + totalIncluding.toLocaleString(); orders.totalOrder.value = "R " + theTotalOrder.toLocaleString(); } return calcTotals(orderValue); } Code: <!-- Row 10, Col 1 Order Value exluding Vat --> <tr><td colspan="2" align="right">Order Value Excluding Vat:</td> <!-- Row 10, Col 2 Order Value exluding Vat Box--> <td colspan="1" align="left"> <input name="totalExcl" type="text" style="margin-left: 60px" size="10" onfocus="this.form.elements[0].focus()" /> </td></tr> <!-- Row 11, Col 1 Vat of 15% --> <tr><td colspan="2" align="right">Vat calculated at 15%:</td> <!-- Row 11, Col 2 Vat Value Box--> <td colspan="1" align="left"><input name="vat" style="margin-left: 60px" type="text" size="10" readonly="readonly" /> </td></tr> <!-- Row 12, Col 1 Total Order Value including Vat --> <tr><td colspan="2" align="right">Order Value Including Vat:</td> <!-- Row 12, Col 2 otal Order Value including Vat Box--> <td colspan="1" align="left"><input name="totalIncl" style="margin-left: 60px" type="text" size="10" readonly="readonly" /> </td></tr> <!-- Row 13, Col 1 Order Value --> <tr><td colspan="2" align="right">Delivery Options: <input type="radio" name="sapo" value="35" onclick="delivery.value='R ' + this.value" /> R35 - SA Post Office <input type="radio" name="sapo" value="80" onclick="delivery.value='R ' + this.value" /> R80 - Speed Services <input type="radio" name="sapo" value="150" onclick="delivery.value='R ' + this.value" /> R150 - Courier Services </td> <!-- Row 13, Col 2 Order Value Box--> <td colspan="1" align="left"><input name="delivery" style="margin-left: 60px" type="text" size="10" readonly="readonly" /> </td></tr> <!-- Row 14, Col 1 Total Order Value including Vat --> <tr><td colspan="2" align="right"><strong>Total Order Value:</strong></td> <!-- Row 14, Col 2 otal Order Value including Vat Box--> <td colspan="1" align="left"><input name="totalOrder" style="margin-left: 60px" type="text" size="10" readonly="readonly" /> </td></tr> Hey, I'm looking for some help with something I have been developing over the last day or so. Basically, I have a form with some input boxes in it, and I am trying to use some javascript to do a calculation with these input boxes. The problem is that when I go to click on the "calculate" button nothing happens. The fields where the value should go to I have made visible instead of hidden to make sure that something is going there but nothing is appearing. I've checked various parts of my syntax with online checkers and other javascript examples and I'm stuck as to what has gone wrong. If anyone can shed some light on the problem and possible solutions that would be awesome. I am using Macromedia Dreamweaver MX2004 to develop this. I have added the code below for the entire test html page: Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> #calc_container { padding-right: 25px; padding-left: 25px; width: 900px; } .calculator_text1 { color: #FFFFFF } </style> <script type="text/javascript"> function Combat() { var Attack = (document.Combat_Calculator.Combat_Attack.value); var Strength = (document.Combat_Calculator.Combat_Strength.value); var Defence = (document.Combat_Calculator.Combat_Defence.value); var Constitution = (document.Combat_Calculator.Combat_Constitution.value); var Magic = (document.Combat_Calculator.Combat_Magic.value); var Ranged = (document.Combat_Calculator.Combat_Ranged.value); var Prayer = (document.Combat_Calculator.Combat_Prayer.value); var Summoning = (document.Combat_Calculator.Combat_Summoning.value); var Sum_Melee = parseInt(0.25 * ((1.3 * (Attack + Strength)) + Defence + Constitution + (0.5 * Prayer))); var Sum_Magic = parseInt(0.25 * ((1.3 * (2 / 3 * Magic)) + Defence + Constitution + (0.5 * Prayer))); var Sum_Ranged = parseInt(0.25 * ((1.3 * ( 2 / 3 * Ranged)) + Defence + Constitution + (0.5 * Prayer))); document.Combat_Calculator.Combat_Sum_Melee.value = (Sum_Melee); document.Combat_Calculator.Combat_Sum_Magic.value = (Sum_Magic); document.Combat_Calculator.Combat_Sum_Rangedr.value = (Sum_Ranged); } function MM_callJS(jsStr) { return eval(jsStr) } </script> </head> <body> <div id="calc_container" onselectstart="return false"> <form action="" method="post" name="Combat_Calculator" id="Combat_Calculator"> <table width="822" border="10" bordercolor="#2E2E2E" bgcolor="2E2E2E"> <tr bgcolor="2E2E2E"> <td width="87" height="15"></td> <td width="146" height="15"></td> <td width="122" height="15"></td> <td width="145" height="15"></td> <td width="37" height="15" bgcolor="2E2E2E"></td> <td width="179" height="15"></td> <td width="56" height="15"></td> </tr> <tr> <td height="58" colspan="7" bgcolor="#FFFFFF"><div align="right"></div> <div align="center">Your combat level is:<input name="Free_Player" type="text" id="Free_Player" maxlength="3" disabled="disabled" style="background-color:#FFFFFF; border:none;"> +<input name="Member" type="text" id="Member" maxlength="2" disabled="disabled" style="background-color:#FFFFFF; border:none;"> </div><div align="right"></div><div align="center"></div><div align="right"></div><div align="center"></div></td> </tr> <tr> <td height="15"><div align="right" class="calculator_text1">Attack:</div></td> <td height="15" bgcolor="2E2E2E"><input name="Combat_Attack" maxlength="2" type="text" id="Combat_Attack"></td> <td height="15"><div align="right" class="calculator_text1">Magic:</div></td> <td height="15" bgcolor="2E2E2E"><input name="Combat_Magic" maxlength="2" type="text" id="Combat_Magic"></td> <td width="37" height="15" bgcolor="2E2E2E"></td> <td height="15" bgcolor="2E2E2E"></td> <td height="15" bgcolor="2E2E2E"></td> </tr> <tr> <td height="15"><div align="right" class="calculator_text1">Strength:</div></td> <td height="15" bgcolor="2E2E2E"><input name="Combat_Strength" maxlength="2" type="text" id="Combat_Strength"></td> <td height="15"><div align="right" class="calculator_text1">Ranged:</div></td> <td height="15" bgcolor="2E2E2E"><input name="Combat_Range" maxlength="2" type="text" id="Combat_Range"></td> <td width="37" height="15" bgcolor="2E2E2E"></td> <td height="15" bgcolor="2E2E2E"><div align="center"> <input name="Combat_Calculate" type="button" id="Combat_Calculate" onClick="MM_callJS('Combat();')" value="Calculate"></div></td> <td height="15" bgcolor="2E2E2E"></td> </tr> <tr> <td height="15"><div align="right" class="calculator_text1">Defence:</div></td> <td height="15" bgcolor="2E2E2E"><input name="Combat_Defence" maxlength="2" type="text" id="Combat_Defence"></td> <td height="15"><div align="right" class="calculator_text1">Prayer:</div></td> <td height="15" bgcolor="2E2E2E"><input name="Combat_Prayer" maxlength="2" type="text" id="Combat_Prayer"></td> <td width="37" height="15" bgcolor="2E2E2E"></td> <td height="15" bgcolor="2E2E2E"></td> <td height="15" bgcolor="2E2E2E"></td> </tr> <tr> <td height="15"><div align="right" class="calculator_text1">Constituion:</div></td> <td height="15" bgcolor="2E2E2E"><input name="Combat_Constitution" maxlength="2" type="text" id="Combat_Constitution"></td> <td height="15"><div align="right" class="calculator_text1">Summoning:</div></td> <td height="15" bgcolor="2E2E2E"><input name="Combat_Summoning" maxlength="2" type="text" id="Combat_Summoning" ></td> <td width="37" height="15" bgcolor="2E2E2E"></td> <td height="15" bgcolor="2E2E2E"></td> <td height="15" bgcolor="2E2E2E"></td> </tr> </table> <p><input name="Combat_Sum_Melee" type="text" id="Combat_Sum_Melee">Melee</p> <p><input name="Combat_Sum_Magic" type="text" id="Combat_Sum_Magic">Magic</p> <p><input name="Combat_Sum_Range" type="text" id="Combat_Sum_Range">Range</p> </form> </div> </body> </html> Edit: I have edited the code to remove/change the things that "Philip M" kindly pointed out were not needed and a bit of re-designing the page. I still can't get the javascript to put the answer value in the correct place on the click of the button. I'm under the impression it has something to do with the button rather than the javascript code but I might be wrong. 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 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 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 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. 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 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(); 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 ... 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 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." ?> I've run into a glitch in my little calculator form. Apparently, in Safari, when you hit the enter key while the cursor is in an input field, it will attempt to submit the form. I don't want this to happen. Submitting serves no purpose in this, because all of the functionality is in the script on the page. I copied most of the HTML from an example, and noted that the form tag didn't contain an action= parameter. I tried adding this with the hopes that it would override Safari's default submit action. They do affect its behavior, but not in a way that does any good. First, I tried: action="" which didn't work Then, I tried: action="CalcRange()" This is a harmless function that normally runs on field change. It didn't work either. In every case Safari is determined to fire off a URL. No problems with MSIE or Firefox. Is there another way of using the action parameter to fix the problem, or do I have to attack this another way. Thanks. Code: <html><head><title></title> <script language="JavaScript"> var d = null; function PadCalc(ctrm,cvlo,cvhi,cstray,rc) { chp = cvhi+ctrm; clp = cvlo+ctrm; beta=(rc-1)*cstray; a=rc* clp- chp +beta; b= (rc-1)*clp*chp+beta*(clp + chp); c=beta*clp* chp; cser=(-b-Math.sqrt(b*b-4*a*c))/(a+a); return(cser); } function TrmCalc(cser,cvlo,cvhi,cstray,rc) { if (cser<0.00001) { ctrm=(cvhi+cstray-rc*(cvlo+cstray))/(rc-1); } else { cser2=cser*cser; k0=(1-rc)*cstray; k1=k0*cser2; k2=k0*cser+cser2; k3=k0*cser-rc*cser2; k4=k0+(1-rc)*cser; a=k4; b=k2+k3+k4*(cvlo+cvhi); c=k1+k2*cvhi+k3*cvlo+k4*cvlo*cvhi; ctrm=(-b-Math.sqrt(b*b-4*a*c))/(a+a); } return(ctrm); } function setCellTxt(id,tx,clr){ cell=document.getElementById(id); cell.innerHTML=tx; cell.style.color=clr; } function CalcAll() { setCellTxt("ex_cpar","***","#FF0000"); setCellTxt("ex_cser","***","#FF0000"); setCellTxt("ex_L","***","#FF0000"); flo = parseFloat(d.ef_flo.value); fhi = parseFloat(d.ef_fhi.value); cvlo = parseFloat(d.ef_cvlo.value); cvhi = parseFloat(d.ef_cvhi.value); cstray = parseFloat("0".concat(d.ef_cstray.value)); KVal = parseFloat(d.ef_KVal.value); spi = 500000.0/Math.PI; rf=fhi/flo; rc=rf*rf; switch(d.mknown.selectedIndex){ case 0: // For Given inductor L = KVal; w=(spi/flo) chppp = w*w/L; w=(spi/fhi) clppp = w*w/L; alpha = cstray-chppp; beta = cstray-clppp; k1 = cvhi-chppp-cvlo+clppp; k2 = alpha - beta; k3 = alpha*cvhi - beta*cvlo; k4 = alpha*cvhi; k5 = cvhi + alpha; a = -k2/k1; b = alpha-(k3+k2*k5)/k1; c = k4-(k3*k5)/k1; ctrm = (-b+Math.sqrt(b*b-4*a*c))/(a+a); cser = -(k2*ctrm+k3)/k1; if (cser>100*cvhi) cser=0; // End of given L calc break; case 1: // For Given Padder cser=KVal; if (cser<.00001) { cpinv=0; } else { cpinv=1/cser; } ctrm=TrmCalc(cser,cvlo,cvhi,cstray,rc); chp=cvhi+ctrm; chppp=1/(1/chp+cpinv)+cstray; w=spi/flo; L=w*w/chppp; break; case 2: // For Given Trimmer ctrm=KVal; cser=PadCalc(ctrm,cvlo,cvhi,cstray,rc); chppp=chp*cser/(chp+cser)+cstray; if (cser>100*cvhi) cser=0; w=spi/flo; L=w*w/chppp break; } badVal=false; if (isNaN(ctrm) || ctrm<0) badVal=True; if (isNaN(cser) || cser <0) badVal=True; if (isNaN(L) || L<0) badVal=True; if (!badVal) { setCellTxt("ex_cpar",ctrm.toFixed(2),"#000080"); setCellTxt("ex_cser",cser.toFixed(2),"#000080"); setCellTxt("ex_L",L.toFixed(2),"#000080"); } } function CalcRange() { flo = parseFloat(d.ef_flo.value); fhi = parseFloat(d.ef_fhi.value); cvlo = parseFloat(d.ef_cvlo.value); cvhi = parseFloat(d.ef_cvhi.value); cstray = parseFloat("0".concat(d.ef_cstray.value)); if (flo>0 && fhi>0 && cvlo>0 && cvhi>0) { spi = 500000.0/Math.PI; rf=fhi/flo; rc=rf*rf; csmin=PadCalc(0,cvlo,cvhi,cstray,rc); ctmax=TrmCalc(0,cvlo,cvhi,cstray,rc); w=spi/flo chppp=cvhi*csmin/(cvhi+csmin)+cstray; Lmax=w*w/chppp; chppp=cvhi+ctrm+cstray; Lmin=w*w/chppp; //Reset exact calc outputs after input parameter change /* setCellTxt("ex_cpar","","#000080"); setCellTxt("ex_cser","","#000080"); setCellTxt("ex_L","","#000080"); */ if (Lmin<0 || Lmax<0 || ctmax<0 || csmin<0) { setCellTxt("rTrm","***","#FF0000"); setCellTxt("rPad","***","#FF0000"); setCellTxt("rInd","***","#FF0000"); } else { setCellTxt("rTrm","0 ... ".concat(ctmax.toFixed(2)),"#000080"); setCellTxt("rPad",">= ".concat(csmin.toFixed(2)," (if present)"),"#000080"); setCellTxt("rInd","".concat(Lmin.toFixed(2)," ... ",Lmax.toFixed(2)),"#000080"); } } } function kvChange() { descriptions = Array ("Enter Inductance Value (µH):","Enter Series Capacitance Value (pF):","Enter Parallel Capacitance Value: (pF)"); setCellTxt("KVdescription",descriptions[d.mknown.selectedIndex],"#000080"); setCellTxt("ex_cpar","","#000080"); setCellTxt("ex_cser","","#000080"); setCellTxt("ex_L","","#000080"); } </script> </head> <body onload="d = document.forms[0];"> <center> <h2>Bandspread Calculator</h2> </center> <form > <table style="width: 692px; height: 400px;" align="center" border="0"> <tbody> <tr> <td align="center" colspan=2"><B>Input Parameters:</B></td> </tr> <tr> <td align="right">Lowest Frequency (kHz):</td> <td><input name="ef_flo" onchange="CalcRange()" size="18"> </td> </tr> <tr> <td align="right">Highest Frequency (kHz):</td> <td><input name="ef_fhi" onchange="CalcRange()" size="18"> </td> </tr> <tr> <td align="right">Tuning Capacitor <I>C<sub>V</sub></I> Minimum Capacitance (pF):</td> <td><input name="ef_cvlo" onchange="CalcRange()" size="18"> </td> </tr> <tr> <td align="right">Tuning Capacitor <I>C<sub>V</sub></I> Maximum Capacitance (pF):</td> <td><input name="ef_cvhi" onchange="CalcRange()" size="18"> </td> </tr> <tr> <td align="right">Stray Capacitance <I>C<sub>S</sub></I> (pF):</td> <td><input name="ef_cstray" onchange="CalcRange()" size="18"> </td> </tr> <tr> <td align="center" colspan=2"><HR></td> </tr> <tr> <td align="center" colspan=2"><B>Allowable Component Ranges:</B></td> </tr> <tr> <td align="right">Trimmer Capacitor <I>C<sub>T</sub></I> (pF): </td> <td align="left" id="rTrm"><font color="#FF0000">***</font></td> </tr> <tr> <td align="right">Padder Capacitor <I>C<sub>P</sub></I> (pF): </td> <td align="left" id="rPad" ><font color="#FF0000">***</font></td> </tr> <tr> <td align="right">Inductor (µH): </td> <td align="left" id="rInd"><font color="#FF0000">***</font></td> </tr> <tr> <td align="center" colspan=2"><HR></td> </tr> <tr> <td align="center" colspan=2"><B>Exact Value Calculation:</B></td> </tr> <tr> <td align="right">Choose the Known Component:</td> <td> <select name="mknown" onchange="kvChange()" size="1"> <option selected="selected">Inductor</option> <option>Padder Capacitor (Series)</option> <option>Trimmer Capacitor (Parallel)</option> </select> </td> </tr> <tr> <td id="KVdescription" align="right">Enter the Known Component Value:</td> <td><input name="ef_KVal" size="18"></td> </tr> <tr> <td align="right">Click to Calculate the Unknown Components:</td> <td><input type="button" value="Calculate" onclick="CalcAll()"> </td> </tr> <tr> <td align="right">Trimmer Capacitor <I>C<sub>T</sub></I> (pF): </td> <td id="ex_cpar" > </td> </tr> <tr> <td align="right">Padder Capacitor <I>C<sub>P</sub></I> (pF): </td> <td id="ex_cser"> </td> </tr> <tr> <td align="right">Inductor (µH): </td> <td id="ex_L"> </td> </tr> </tbody> </table> </form> </body></html> Edit: I should also add that my web page is made using Apple's iWeb software, and it stores the above code in a separate file, and then uses the following iframe code to load it: Code: <iframe id="widget1-frame" src=".//BandspreadCalc_files/widget1_markup.html" frameborder="0" style="width: 100%; height: 100%;" scrolling="no" marginheight="0" marginwidth="0" allowTransparency="true"></iframe> So, when Safari submits the form, the result is that it loads a page containing only the widget1_markup.html code, and not the parent page. Either way, it's annoying, because any data that the user has entered in a field will be erased. 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(); Good day all: I want to get the value of a textbox into php without clicking the submit button. Any advice... Here is what I have My form field: Code: #1 <input type="text" style=background:transparent; border:0px; name='clientid' > This field is populated dynamically by its name with another php script in this way Code: #2 echo "formObj.clientid.value = '".toSafeString($inf["clientID"])."';\n"; Now I want to take the value in code#1 (name='clientid') and pass it to a php code that is in the same file as the form. Here is the php code PHP Code: <?php $name=$_POST['name'];//this is where the value of the text box mentioned is defined include 'datalogin.php'; error_reporting(0); error_reporting(E_ERROR | E_WARNING | E_PARSE); //test //get image details $uploaddir = "images/clientsimages/"; $get_data = "SELECT i.uploadedfile, i.clientid " . " FROM images AS i, ajax_client AS a " . " WHERE i.clientid = a.clientID " . " AND a.clientID = $name"; $get_data_res = mysql_query($get_data) or die(mysql_error() . '<br>sql : '.$get_data); if (mysql_num_rows($get_data_res) > 0) { while ($get_data_info = mysql_fetch_array($get_data_res)) { $uploadedfile = $uploaddir . $get_data_info["uploadedfile"]; } } ?> I know this may require js, but I appreciate any help! I was curious if there is a method to keep a single input from submitting a form. I have an input into which I'm building a drop down search feature, however, I'd like it so when the user presses return there, instead of submitting the form, it runs an AJAX POST instead. I am currently using keyUp to recognize the button press, but its still submitting the form its attached to. Obviously, I'd like that not to happen. 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> |