/    Sign up×
Community /Pin to ProfileBookmark

submit form in popup window

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 ?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliJun 18.2003 — It seems like its because of this without seeing your rest of the code


return false;

in the form element

make it return true;
Copy linkTweet thisAlerts:
@jayke00authorJun 19.2003 — 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>&nbsp;</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>&nbsp;</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>&nbsp;</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>&nbsp;</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>&nbsp;</td>

<td width="50%">&nbsp;</td>

</tr>

<tr valign="middle">

<td valign="top" width="50%"> <div align="right"></div></td>

<td>&nbsp;</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 ?
Copy linkTweet thisAlerts:
@Khalid_AliJun 19.2003 — 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();

}
Copy linkTweet thisAlerts:
@f4265Jun 20.2003 — 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?
×

Success!

Help @jayke00 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...