Click to See Complete Forum and Search --> : submit form in popup window
jayke00
06-18-2003, 06:49 PM
Hey,
Im trying to get a form to submit its inputs to another page that opens in a new window when the form is submitted.
<form action="submit_question.php" method="POST" name="question" onSubmit="window.open('submit_question.php', 'popupwindow', 'width=300,height=200,resizable'); return false;">
The above code will open the correct page in a popup window, but will not submit the entered values.
Does anyone know what I can do?
Thanks :)
Khalid Ali
06-18-2003, 06:52 PM
It seems like its because of this without seeing your rest of the code
return false;
in the form element
make it return true;
jayke00
06-18-2003, 07:02 PM
When a change it to return true both the main page, and the popup go to 'submit_question.php'. The popup still doesnt submit the wanted values. Here is the full form code:
<form action="submit_question.php" method="POST" name="question" onSubmit="window.open('submit_question.php', 'popupwindow', 'width=300,height=200,resizable'); return false;">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr valign="middle">
<td width="50%" valign="top"> <div align="right"><font color="#777777" face="Verdana, Arial, Helvetica, sans-serif">Name
:</font></div></td>
<td><input name="name" type="text"> </td>
</tr>
<tr valign="middle">
<td width="50%" valign="top"> <div align="right"><font color="#777777" face="Verdana, Arial, Helvetica, sans-serif">Company
:</font></div></td>
<td> </td>
<td width="50%"> <input name="company" type="text">
</td>
</tr>
<tr valign="middle">
<td width="50%" valign="top"> <div align="right"><font color="#777777" face="Verdana, Arial, Helvetica, sans-serif">Email
:</font></div></td>
<td> </td>
<td width="50%"> <input name="email" type="text"> </td>
</tr>
<tr valign="middle">
<td width="50%" valign="top"> <div align="right"><font color="#777777" face="Verdana, Arial, Helvetica, sans-serif">Phone
:</font></div></td>
<td> </td>
<td width="50%"> <input name="phone" type="text">
</td>
</tr>
<tr valign="middle">
<td width="50%" valign="top"> <div align="right"><font color="#777777" face="Verdana, Arial, Helvetica, sans-serif">Inquiry
:</font></div></td>
<td> </td>
<td width="50%"> <textarea name="message" rows="8" wrap="VIRTUAL"></textarea>
</td>
</tr>
<tr valign="middle">
<td valign="top" width="50%"> <div align="right"></div></td>
<td> </td>
<td width="50%"> </td>
</tr>
<tr valign="middle">
<td valign="top" width="50%"> <div align="right"></div></td>
<td> </td>
<td width="50%"> <div align="left">
<input name="send" type="submit" class="btn_med" id="send" onClick="MM_validateForm('name','','R','email','','RisEmail','message','','R');return document.MM_returnValue" value="Contact Us">
<br>
</div></td>
</tr>
</table>
</form>
Thanks :)
Khalid Ali
06-19-2003, 09:12 AM
It seesm like there is some morethinking required on this topic,the logic doesn't seem right,anyhow,if you must do it in the exact same manner,remove the onsubmit event from the form element so that it looks like this
<form action="submit_question.php" method="POST" name="question" >
then make these changes to your submit button
<input name="send" type="button" class="btn_med" id="send" onClick=" MM_validateForm('name','','R','email','','RisEmail
','message','','R');return document.MM_returnValue;Process();" value="Contact Us">
ANd finally in the javascript section define Process as follows
function Process(){
//first open window
var popupwindow= window.open('submit_question.php', 'popupwindow', 'width=300,height=200,resizable');
//now that window is opened you want to submit the form
//you could add a little time delay here as well..read up on setTiemout function.
document.question.submit();
}
f4265
06-20-2003, 12:38 PM
In the process function in the window.open method what does one do if the form action is on a different server and one must use the full url. I.E. 'http://www.anotherserver.com/my script.cgi'
The // after the http: appears to comment out the rest of the line. Is there away to escape them?