Gossamer Forum
Home : General : Internet Technologies :

<form> submission opens new window (or not)

Quote Reply
<form> submission opens new window (or not)
I would like to make a html form with two submit buttons. The requirements are that when one button is pressed, the form data is submitted and the new page is displayed in the same browser window, but when the other button is pressed, the form data is submitted and a new browser window is opened?

Is this possible, and if yes, how would I do this?

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] <form> submission opens new window (or not) In reply to
Have a look at the script below:

<script>
function submit_form() {
myform.target = "new_window_name";
myform.submit();
}
</script>
<form name="myform" method="post" action="">
<input type="submit" name="button1" value="Button 1">
<input type="button" name="button2" value="Button 2" onclick="submit_form()">
....
</form>

Hope that helps.

TheStone.

B.
Quote Reply
Re: [TheStone] <form> submission opens new window (or not) In reply to
Thanks a lot for the reply.

I tried the script (which seems to be precisely what I need), but it didn't work, both buttons opened the new page in the existing window.

Any ideas what could be wrong? My javascript is non-existant, sorry...

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] <form> submission opens new window (or not) In reply to
Not sure about browser-compatability, but you could try;

<form method="POST" action="script.cgi" target=_blank>

Just tried it here, and it works ok (IE 5.5).

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] <form> submission opens new window (or not) In reply to
But if I add a target=_blank to the form tag, it will open a new page for both buttons, won't it?

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] <form> submission opens new window (or not) In reply to
Sorry, misread your post Crazy

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [TheStone] <form> submission opens new window (or not) In reply to
Tried, and found this (working with NS/Mozilla):

Code:
<script>
function submit_form(object) {
object.target = "new_window_name";
object.submit();
}
</script>
<form name="myform" method="post" action="">
<input type="submit" name="button1" value="Button 1">
<input type="button" name="button2" value="Button 2" onClick="submit_form(myform)">
</form>

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [Andy] <form> submission opens new window (or not) In reply to
Does anyone know how I would set the window attributes of the newly opened window in this example?

Thanks.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] <form> submission opens new window (or not) In reply to
Open a new window first, then reference the name you gave it.

function newdealWin(dealForm) {
window.open("", "newWin", "width=400,height=400,scrollbars");

dealForm.target = "newWin";
dealForm.submit();
}
Quote Reply
Re: [yogi] <form> submission opens new window (or not) In reply to
I have the same problem. I spent about 2 hours trying to have it to work.

Could some one send me a complete example of form that opens in a new centered browser window with only the navigation bar (toolbar=yes,scrollbars=yes,resizable=yes,width=750,height=400)

I need to have it to work with Netscape 4 and Internet Explorer 6.

Thant would be cool. Thanks,

Charles.
Quote Reply
Re: [yogi] <form> submission opens new window (or not) In reply to
Hi Ivan. I'm trying to use some similar code now. The problem is, that the form data doesn't seem to be getting passed through at all? (when using the javascript function).

Did you manage to solve this problem?

TIA

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!