form submission in a popup

F

Flex

Hi everybody,
what's the code for a form submission in a new window? i wasn't sure it it
should go in the form action tag, or in the submit button.
I tried something like this:
<form name="frmContact" method="POST"
action="javascript:window.open('send_email.asp',null,'width=450, height=225,
status=no, directories=no, toolbar=no, location=no, menubar=no,
scrollbars=no, resizable=no');" onSubmit="return CheckForm();" >

but it don't work:
i 've a new window but no parameters + " [object Window] " write on the
first page

help,
please
Thanks
 
C

Colin McKinnon

Flex said:
Hi everybody,
what's the code for a form submission in a new window? i wasn't sure it it
should go in the form action tag, or in the submit button.
I tried something like this:
<form name="frmContact" method="POST"
action="javascript:window.open('send_email.asp',null,'width=450,
height=225, status=no, directories=no, toolbar=no, location=no,
menubar=no,
scrollbars=no, resizable=no');" onSubmit="return CheckForm();" >

I could be wrong but I don't thnk it's possible to 'submit' to a different
window.

Easiest would be to have no submit, but have a button which opens the window
with a GET (I don't think javascript provides a urlencode function so you'd
need to write that too:

<script>
function sortOfSubmit()
{
var url='send_email.asp?';
url+='field=' + urlencode(form.field.value);
url+='&other=' + urlencode(form.other.value);
// ...
window.open(url,null,'width=450,
height=225, status=no, directories=no, toolbar=no, location=no,
menubar=no,scrollbars=no, resizable=no')

}
<input type='button' value='sort of submit' onclick='sortOfSubmit()'>
</script>

Alternatively open the popup with a form and javascript to copy over the
fields from window.opener, then submit itself.

HTH

C.
 
E

Erwin Moller

Flex said:
Hi everybody,
what's the code for a form submission in a new window? i wasn't sure it it
should go in the form action tag, or in the submit button.
I tried something like this:
<form name="frmContact" method="POST"
action="javascript:window.open('send_email.asp',null,'width=450,
height=225, status=no, directories=no, toolbar=no, location=no,
menubar=no,
scrollbars=no, resizable=no');" onSubmit="return CheckForm();" >

Try adding target in your formdefinition:

<form action="bla.php" method="POST" target="myOtherWindow">

Of course, if you want myOtherWindow to have/have not scrollbars etc. etc,
you must create it first.
If not, a defaultbrowserwindow will open.

Regards,
Erwin Moller

but it don't work:
i 've a new window but no parameters + " [object Window] " write on the
first page

help,
please
Thanks
 
F

Flex

thanks
I 'm going to try it

Colin McKinnon said:
I could be wrong but I don't thnk it's possible to 'submit' to a different
window.

Easiest would be to have no submit, but have a button which opens the
window
with a GET (I don't think javascript provides a urlencode function so
you'd
need to write that too:

<script>
function sortOfSubmit()
{
var url='send_email.asp?';
url+='field=' + urlencode(form.field.value);
url+='&other=' + urlencode(form.other.value);
// ...
window.open(url,null,'width=450,
height=225, status=no, directories=no, toolbar=no, location=no,
menubar=no,scrollbars=no, resizable=no')

}
<input type='button' value='sort of submit' onclick='sortOfSubmit()'>
</script>

Alternatively open the popup with a form and javascript to copy over the
fields from window.opener, then submit itself.

HTH

C.
 
B

bluesrift

Erwin said:
Of course, if you want myOtherWindow to have/have not scrollbars etc. etc,
you must create it first.
If not, a defaultbrowserwindow will open.

Creating a new window then posting to it creates challenges having
to do with the timing of the new window to accept input. I
struggled with that for a long time and finally arrived at the
solution of creating an interim page with an onload that submits
the opener form to the new window(in which the interim page
resides).

opener.document.THEFORMNAME.submit()

Lately I've been working on the concept of avoiding a post
completely by reading in the contents of the opener form from within
the new window. This seems to be a viable cgi-less / bandwidth
reducing alternative.

So far I found something interesting I'd like to share. There's
always more than one way to skin a cat and I've found, for some
reason, that reading in a form like this:

with (opener.document.THEFORMNAME) {
for (i=0; i < elements.length; i++) {
// processing occurs here
}
}

operates very much more slowly than this method:

for (i=0; i < opener.document.THEFORMNAME.length; i++) {
// processing occurs here
}

The iterations are the same so I wonder if anyone
here knows why there is such a performance difference?

Also, any similar tips will be appreciated.

Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top