/    Sign up×
Community /Pin to ProfileBookmark

How to return form data to parent window

Everyone,

This is probably a really basic question but I have a pop-up window that is supposed to send data back to the parent window. The problem is that once people enter data in the pop-up window, the parent or top window is not refreshed.

How do I make the parent window back as the primary recipient of the data. If I put the original page in the <form action parameter, everything happens in the pop-up window. I know I need to put top.window before the original page name but that doesn’t seem to work.

Is there another way to stipulate the original parent window in the form action or onSubmit() event? Thanks!

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangAug 17.2008 — Parent:&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;title&gt;parent&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;

&lt;script type="text/javascript"&gt;
var childRef;

function popup(child) {
childRef = window.open(child, "childName", "width=400,height=500");
}
&lt;/script&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;form action="#" name="formParent"&gt;
&lt;div&gt;
&lt;a onclick="popup(this.href); return false;" href="child.htm"&gt;popup&lt;/a&gt;
&lt;input type="text" name="result" disabled&gt;
&lt;/div&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

Child:&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;title&gt;child&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;

&lt;/head&gt;
&lt;body&gt;
&lt;form action="#" name="formChild" onsubmit="opener.document.formParent.result.value=document.formChild.childInput.value; return false;"&gt;
&lt;div&gt;
&lt;input type="text" name="childInput"&gt;
&lt;button type="submit"&gt;submit&lt;/button&gt;
&lt;/div&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@davidbaltAug 21.2008 — another way to do this is to use more modern Ajax techniques to create a "virtual popup" using floating DIVs or more complex "modal dialog" scripts. You will also have the added advantage of not triggering popup blockers.
×

Success!

Help @totally_confuse spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.27,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...