WA
04-30-2003, 09:52 PM
I was emailed this question yesterday, and it got me rather curious. Is there a reliable way to use a new window to process/submit a form once the "submit" button has been clicked? The basic target attribute works, though it obviously doesn't allow one to specify the dimensions/attributes of the new window:
<form action="submit.pl" method="post" target="formwindow">
<input type="text" size="15" value="Testing">
<input type="submit" value="Submit!">
Now, the person who emailed me also included the following script, which he says does work with more refinely tuning the popup window, though it only works when the method="get":
<script>
function submitForm(theform) {
var formwindow= window.open(theform.action, "targetwindow", "width=400,height=400");
}
</script>
<form name="sampleform" action="YOUR-URL" method="GET" target="targetwindow">
contents of your form...
<input type="button" onClick="submitForm(document.forms.sampleform);">
</form>
How is method="post" different as far as JavaScript's ability to process the form in a new window?
Thanks,
<form action="submit.pl" method="post" target="formwindow">
<input type="text" size="15" value="Testing">
<input type="submit" value="Submit!">
Now, the person who emailed me also included the following script, which he says does work with more refinely tuning the popup window, though it only works when the method="get":
<script>
function submitForm(theform) {
var formwindow= window.open(theform.action, "targetwindow", "width=400,height=400");
}
</script>
<form name="sampleform" action="YOUR-URL" method="GET" target="targetwindow">
contents of your form...
<input type="button" onClick="submitForm(document.forms.sampleform);">
</form>
How is method="post" different as far as JavaScript's ability to process the form in a new window?
Thanks,