JavaScript - Submitting The Form Back To Previous Window?
Hi all,
I am using some Javascript to open up a pop up window... Code: <script type="text/javascript"> //<![CDATA[ function editText() { sList = window.open("editText.php", "list", "width=300,height=300,scrollbars=Yes"); } //]]> </script> This works fine and within that popup window I have the following: Code: <form action="index.php" method="post"> <textarea name="userInput" id="userInput" cols="32" rows="10"><?php echo $_SESSION['greeting'];?></textarea> <input type="submit" name="updateText" id="updateText" value="Update Text" onclick="changeText2()"/> </form> The idea is to send the value of the form back to index.php so I can perform the following check: PHP Code: if(isset($_POST['updateText'])) { $userInput = $_POST['userInput']; $product->greeting = "I am set"; echo $product->greeting; } else { $product->greeting = "I am not set"; echo $product->greeting; } However because the form is opening in a popup window, when submitting it is loading index.php in the new popup window. What I need to do is somehow close the popup and send the data back to the original page. I know of window.close but if I call this, then form will not run. Can any body help me here... alternatively I was trying to do the following: Code: <script type="text/javascript"> function changeText2(){ var userInput = document.getElementById('userInput').value; window.opener.document.getElementById('element-greeting-content').innerHTML = userInput; window.close('editText.php'); } </script> <textarea name="userInput" id="userInput" cols="32" rows="10"><?php echo $_SESSION['greeting']; ?></textarea> <input type='button' onclick='changeText2()' value='Update Text'/> but doing it this way meant that the value wasn't been passed to be checked in an if statement. Any help would be greatly appreciated. Similar TutorialsI have an application I'm working on and here is what I'm trying to do: I want users to work from a main application. Certain things will need to be done but the users wont want to see the main screen go away while doing these certain things. So my idea is to just open a new window with the content they need, they'll make their changes, the new window will close but then I want the main page to reload. What I've done now is at the end of the script that will be run prior to the new window closing is added this (its a php app): Code: echo "<script>window.close();</script>"; echo "<script>window.opener.location.reload(true);</script>"; Sometimes this works in IE and Firefox but never in Chrome. I know I've seen this done before on other sites, but I cant think of what they are. Can anyone tell me a reliable way that works in all browsers? Hi, I am using Javascript to display options in a form with 2 dropdown lists. However, despite using the rel="nofollow" target='_self', the result opens in a new window. Help would be much appreciated. Code: // JavaScript Document function setOptions(chosen) { var selbox = document.ChronoContact_course_finder.opttwo; selbox.options.length = 0; if (chosen == ' ') { selbox.options[selbox.options.length] = new Option('Choose Option',' '); } if (chosen == '85') { selbox.options[selbox.options.length] = new Option('ITEC Beauty Specialist Diploma','index.php?option=com_content&view=article&id=49&Itemid=68',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('ITEC Professional Makeup','index.php?option=com_content&view=article&id=57&Itemid=76',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('Fashion Catwalk & Photographic Makeup Course','index.php?option=com_content&view=article&id=67&Itemid=91',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('Bridal Makeup Course','index.php?option=com_content&view=article&id=68&Itemid=92',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('Special Effects Makeup','index.php?option=com_content&view=article&id=56&Itemid=77',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('Gel Nails Course','index.php?option=com_content&view=article&id=65&Itemid=88',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('Acrylic Nails Course','index.php?option=com_content&view=article&id=66&Itemid=89',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('Spray Tanning Course','index.php?option=com_content&view=article&id=55&Itemid=73',rel="nofollow" target='_self'); } if (chosen == '69') { selbox.options[selbox.options.length] = new Option('ITEC Holistic Massage Course','index.php?option=com_content&view=article&id=51&Itemid=2',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('ITEC Sports Massage Diploma','index.php?option=com_content&view=article&id=59&Itemid=78',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('Indian Head Massage Course','index.php?option=com_content&view=article&id=60&Itemid=79',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('ITEC Reflexology Diploma','index.php?option=com_content&view=article&id=64&Itemid=87',rel="nofollow" target='_self'); } if (chosen == '80') { selbox.options[selbox.options.length] = new Option('ITEC Teaching Diploma','index.php?option=com_content&view=article&id=61&Itemid=81',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('FETAC Train The Trainer Level 6','index.php?option=com_content&view=article&id=63&Itemid=86',rel="nofollow" target='_self'); } if (chosen == '83') { selbox.options[selbox.options.length] = new Option('ITEC Sports Massage Diploma','index.php?option=com_content&view=article&id=59&Itemid=90',rel="nofollow" target='_self'); } } And the HTML... Code: <div class="form_item"> <div class="form_element cf_heading"> <h1 class="cf_text">course finder</h1> </div> <div class="cfclear"> </div> </div> <div class="form_item"> <div class="form_element cf_dropdown"> <label class="cf_label" style="width: 200px;">Step 1: Choose type of course</label> <select name="optone" class="cf_inputbox" size="1" onchange="setOptions(document.ChronoContact_course_finder.optone.options[document.ChronoContact_course_finder.optone.selectedIndex].value);"> <option value=" " selected="selected">Choose Option</option> <option value="85">Beauty courses</option> <option value="69">Complimentary courses</option> <option value="80">Teaching courses</option> <option value="83">Fitness courses</option> </select> </div> <div class="cfclear"> </div> </div> <div class="form_item"> <div class="form_element cf_dropdown"> <label class="cf_label" style="width: 200px;">Step 2: Choose a subject</label> <select size="1" name="opttwo" class="cf_inputbox" > <option value=" " selected="selected">Choose Option</option> </select> <!--<input type="button" name="go" value="Value Selected" onclick="window.open(document.ChronoContact_course_finder.opttwo.options[document.ChronoContact_course_finder.opttwo.selectedIndex].value);">--> </div> <div class="cfclear"> </div> </div> <div class="form_item"> <div class="form_element cf_button"> <input type="submit" name="go" value="search" onclick="window.open(document.ChronoContact_course_finder.opttwo.options[document.ChronoContact_course_finder.opttwo.selectedIndex].value);"> </div> <div class="cfclear"> </div> </div> Many thanks, Paul [help] i have the big problem,,, how script to make data to new window (after that, output can print) n data from previous window with datatables (datatables.net) and with default header n footer in new window??? case: [datatable] i search with datatable and have 3 record... and show in new window with default header n footer company , and in new window have function to print the record with header and footer. I hope, anybody can help me..Please thank you Hi All, I am using a loop slider to scroll 4 pages. When I am on any page and click through the product on that. I go to the product but when I click the back button, it goes to the start of the slider rather then the page where I left it. How to go back in loop slider from a back button to the page where we left the scroller. Instead of going to the start of the scroller. It is annoying to go back again to start of the page and scroll all pages. Any help, Highly appreciated. Regards, Meenakshi. Code: <html> <head> <script language="javascript"> var myWindow; function christDoes(){ mydWindow=open("secondary.html", "yes"); } </script> </head> <body><form name="myform" method=POST ACTION="sake.html" ><CENTER> <B>ENTER YOUR SUBJECT</B><INPUT TYPE="TEXT" NAME="subject"> <input type="button" name="ok" value="OK" onClick="christDoes()"> </form> </body> </html> Code: <html> <head> <script language="javascript"> function me(){ displayColor(); } function displayColor() { function newWindow(strWin,strURL,intX,intY,intWidth,intHeight){ winChild =window.open(strURL,strWin,'left=' + intX + ', screenX =' + intX + ', top=' + intY + ', screenY=' + intY + ', width=' + intWidth + ', height=' + intHeight + ', scrollbars=yes, toolbar=yes'); } function closeChild(){ if(winChild){ winChild.close(); } } var m=0; var fSubject = self.opener.document.forms[0].subject.value; if(fSubject.length>0){ if(isNaN(fSubject)){fSubject="";} else{opener.alert("Please enter figure");} numSub=parseInt(fSubject); if(numSub==3){var strSub="abcde";} self.document.write("<center>" +"ENTER SUBJECT HERE" +"</center><br>"); var mercy="<HTML><BODY>" mercy +="<CENTER>" sub=new Array(strSub.length); for(var i=0; i<sub.length; i++){ m++; mercy +=m +"<input type='text' name='sub[i].toLowerCase()'>" +"<BR>"; opener.alert("You have entered" +m +"subjects"); } } mercy +="</CENTER></FORM></BODY></HTML><BR></BR>"; self.document.write(mercy +"<BR>"); self.document.bgColor="pink"; newWindow(); document.write("<center><input type=\"button\" name=\"submit\" value=\"SUBMIT\" onclick=\"window.open('child', 'childwin.html')\">" +"</center>"); } </script> </head> <body onload='me()' onFocus="closeChild();" onUnLoad="closeChild()"> <form></form> </body> </html> Code: <HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"> <TITLE></TITLE> <SCRIPT LANGUAGE=javascript> <!-- var fValue = self.opener.document.forms[0].sub1.value; document.write(fValue +"<input type="text" name="sub1.toLowercase()">"); document.write(fValue +"<input type="text" name="sub2.toLowercase()">"); document.write(fValue +"<input type="text" name="sub3.toLowercase()">"); //--> </SCRIPT> </HEAD> <BODY > <form> <form> </BODY> </HTML> To every freelancer guru, words can not measure how grateful I am to you for your selfless service. God will reward you in Jesus name. Please kindly help me in this: All I want to do is to get the values input of the iterated textbox in the second window to appear in the third window with a textbox with each. Hello guys. I've been struggling on how to make this work. I have a problem in Javascript when it comes to passing of value in a input type field. page1.html Code: <html> <head><title></title></head> <form action="" method="post> <input type="text" name="weight" value=""><a href="hw_calculator.html" target="name" onclick="window.open('hw_calculator.html','name','height=270,width=370,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes'); return false;"> calculate </a> </form> </html> hw_calculator.html Code: <html> <head> <title> Height Converter (Metric/Standard) </title> </head> <body> <FORM> <INPUT type=hidden value="(Math.round((P.value * 0.45359)*100))/100" name=K_expr> <INPUT type=hidden value="(Math.round((K.value / 0.45359)*100))/100" name=P_expr> <INPUT type=hidden value="(Math.round((F.value * 30.48 + I.value * 2.54)*100))/100" name=C_expr> <INPUT type=hidden value="(Math.floor(C.value / 30.48))" name=F_expr> <INPUT type=hidden value="(Math.round(((C.value - (Math.floor(C.value / 30.48) * 30.48)) / 2.54)*100))/100" name=I_expr> <INPUT type=hidden value="(Math.round(P.value * 0.45359))" name=K_exprrnd> <INPUT type=hidden value="(Math.round(K.value / 0.45359))" name=P_exprrnd> <INPUT type=hidden value="(Math.round(F.value * 30.48 + I.value * 2.54))" name=C_exprrnd> <INPUT type=hidden value="(Math.floor(C.value / 30.48))" name=F_exprrnd> <INPUT type=hidden value="(Math.round((C.value - (Math.floor(C.value / 30.48) * 30.48)) / 2.54))" name=I_exprrnd> <h2>Height Converter</h2> <table border="0" bgcolor="#FFFF99" cellspacing="6" cellpadding="6"> <tr> <td colspan> <p class="conv" style="margin-top: 10px; margin-bottom: 10px"><b>STANDARD</b></p> </td> <td></td> <td colspan> <p class="conv" style="margin-top: 10px; margin-bottom: 10px"><b>METRIC</b></p> </td> </tr> <tr> <td> <p class="conv" style="margin-top: 10px; margin-bottom: 10px">Feet : <input maxLength=1 size=1 value=0 name=F> Inches : <input maxLength=2 size=1 value=0 name=I> </td> <td> <p class="conv" style="margin-top: 10px; margin-bottom: 10px"> = </p> </td> <td> <p class="conv" style="margin-top: 10px; margin-bottom: 10px"><input maxLength=3 size=1 value=0 name=C disabled> cm.</p> </td> </tr> <tr> <td class="conv" colspan="2"> <input type="button" name="Taste" value="Calculate" onclick="if (rounded.checked == true) { eval('C.value = ' + this.form.C_exprrnd.value); eval('K.value = ' + this.form.K_exprrnd.value) } else { eval('C.value = ' + this.form.C_expr.value); eval('K.value = ' + this.form.K_expr.value) }"> <INPUT type=checkbox name="rounded" value="rounded" checked disabled><font size="1" face="Verdana">Rounded Result</font> </td> </tr> </table> <p class="conv" style="margin-top: 10px; margin-bottom: 10px"> </body> </html> I want the value of Code: <input maxLength=3 size=1 value=0 name=C disabled> , this is from hw_calculator.html, to be passed on the Code: <input type="text" name="weight" value=""> on page1.html. How can I do this? Huge thanks. I have a popup window which display a list of values in a tabular form. I have no problem to do the popup or display the table. The table has two columns; one is the "code" and the other is the "description". When a row is highlighted and the "SELECT" button in the popup window is clicked, I am supposed to pass the "code" of the highlighted row back to an input textfield in the parent window. And I am struggling with it. Would anybody kindly help? I have an HTML page that is making use of JQUERY and many other JQUERY plugins. Inside this HTML page there are 2 different types of iFrames that display PHP forms. One is a normal iFrame: Code: <iframe height="740" allowTransparency="true" frameborder="0" scrolling="auto" style="width:100%;border:none;overflow-x:hidden" src="https://www.website.com/machform/embed.php?id=9" title="Contact Us"><a href="https://www.website.com/machform/view.php?id=9" title="Contact Us">Contact Us</a></iframe> The other makes use of a JQUERY plugin called Shadowbox: Code: <a href="https://www.website.com/machform/embed.php?id=8" rel="shadowbox;width=1100;height=950;player=iframe" class="button1"><span></span><strong>Click Here</strong></a> Inside these iFrames are PHP forms from a PHP form application called MachForm, which is highly customizable. Here are the questions. Ultimately, I want to accomplish 2 things: 1. I would like to send variable information from the PHP form in the iFrame to my HTML page, to be displayed within javascripts. For example: If someone fills out a PHP form in my iFrame and clicks submit, I want to have a JQUERY popup say, "Thank you, [NAME]". 2. When the user submits the form, the action of clicking the submit button in the PHP form should enable #1, above. There needs to be a way to tell the HTML/Javascript that the submit button on the PHP form in the iFrame has been clicked. I realize this is all fairly vague, especially without the addition of more code. However, I am not even sure if I am posting this in the correct forum, since it incorporates a little of several languages and styles. From this point any direction or idea would be very helpful! 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.
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 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 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 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 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 ... 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 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 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. |