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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

closing a popup and submitting at same time

Status
Not open for further replies.

DeepBlerg

Technical User
Jan 13, 2001
224
AU
Hi,
I have a link on a page which opens a popup window that has a form on it. When the user submits the form I want the form data to return to the parent page and close the popup window. How can I do this?

Thanks.
 
First of all, what do you mean by "user submits the form"? The term "submit" means that the data is sent to server and processed via server-side scripts.
If you just want to send the values from pop-up to parent page, it's a different story. You can do it, for example, by simple variables assigning:

window.opener.var1 = document.formName.field1.value;

This will assign the value of some form field from pop-up to variable in parent page named 'var1'.
If this is what you need, just do the same for all desired fields, and close the popup:

function sendAndClose(){
window.opener.var1 = document.formName.field1.value;
window.opener.var2 = document.formName.field2.value;
. . .
self.close();
}

. . .
<input type=&quot;button&quot; onclick=&quot;sendAndClose()&quot;>

Before that it's a good idea to initialize all necessary variables in parent page:
var var1;
var var2;
. . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top