Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

form action=javascript: ... 3

Status
Not open for further replies.

bardley

Programmer
May 8, 2001
121
US
First, since I'm asking a window-opening question, I apologize if it was already answered somewhere else, but I couldn't find a solution.

I have a form, and I need to have the form-handler(the action attribute) open into a new window. I'd use target=_blank, but I need to also be able to automatically close the opened window.
I have used <a href=&quot;javascript: var win=window.open(...)&quot;> before, so I tried <form method=post action=&quot;javascript: var win=window.open(...)&quot;>, and the form actually caused the pop-up, but the POST variables from the form were nowhere to be found.
Any ideas on how to make the form-handler pop-up in a new window??

TIA
Brad Brad Gunsalus
Cymtec Systems, Inc.
bgunsalus@cymtec.com
 
Unfortunatly there is not easy way to do this.

But a solution I did have was to lauch a popup, get all the values from opener.document.form and put them inside a form inside my popup wich was the exact same (except all input elements were hidden) and submit that form in my popup window using form.submit().

It works but it is a bit tough to do.

function reflectForm(fromForm, toForm)
{
var len = fromForm.elements.length;

for(var i = 0; i < len; i++)
{
var eltName = fromForm.elements.name;
var eltValue = fromForm.elements.value;
var eltObject = toForm.elements[eltName];

if(eltObject != null && eltObject != 'undefined')
{
toForm.elements[eltName].value = eltValue;
}
}
} Gary Haran
 
<form action=&quot;whatever&quot; target=&quot;_blank&quot; onSubmit=&quot;setTimeout('window.children.close()',10000)&quot;>

that closes the window after ten seconds, er..it sounds like it should. Didnt test it. Suceess, thats the way you spell success!
Got a question? Ask IMOZRMY!
 
Dookie2k2 has good ideas however once you do a submit on a page the javascript engine shuts off for that particular page.

For example setTimeout(&quot;alert('slim shaddy is not art')&quot;, 10000) should alert after 10 seconds. However if the page is reloaded (or a form submited is the same) before the 10 seconds are up it will never execute.

Hope this helps. Gary Haran
 
heh, wasnt sure if that would work or not. anyway, ive been wondering this too, so you get a star. Suceess, thats the way you spell success!
Got a question? Ask IMOZRMY!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top