/    Sign up×
Community /Pin to ProfileBookmark

Dears,
I want a java script code that opens a a new window (when I click a link or a button

from the original window) with two textboxes & button.
when I click the button the new window will closed a the value of the two TextBoxes

will appear in a two textBoxes in the Original Page (Calling Page).
Thank you

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@JonaNov 20.2004 — [font=trebuchet ms]To open a new window, use the following:[/font]

<i>
</i>&lt;button onclick="window.open('form.html', 'child', 'width=400,height=400')"&gt;Open window&lt;/button&gt;
Copy linkTweet thisAlerts:
@sam7_976authorNov 20.2004 — Ok

Thank you,

But your code is just open a new window,

How i can pass a values in this newlly opend window to the original window.
Copy linkTweet thisAlerts:
@HaganeNoKokoroNov 20.2004 — For this I think you can use the window.opener (in the popup window) to access the form on the main window. Example:

form.html&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/HTML401/strict.dtd"&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;title&gt;Main Form Page&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="main"&gt;
&lt;a href="#" onclick="window.open('popup.html', '_blank', 'width=250, height=100')"&gt;Open popup to edit form&lt;/a&gt;
&lt;form name="theForm" action="" method="POST"&gt;
&lt;div&gt;
&lt;input name="input1" type="text" readonly="readonly"&gt;&lt;label&gt; Input 1&lt;/label&gt;&lt;br&gt;
&lt;input name="input2" type="text" readonly="readonly"&gt;&lt;label&gt; Input 2&lt;/label&gt;&lt;br&gt;
&lt;/div&gt;
&lt;/form&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
popup.html&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/HTML401/strict.dtd"&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;title&gt;Popup Form Page&lt;/title&gt;
&lt;script type="text/javascript"&gt;
function closeSelf() {
window.opener.document.forms['theForm'].input1.value=document.forms['theForm'].input1.value;
window.opener.document.forms['theForm'].input2.value=document.forms['theForm'].input2.value;
window.close();
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="main"&gt;
&lt;form name="theForm" action="" method="POST"&gt;
&lt;div&gt;
&lt;input name="input1" type="text"&gt;&lt;label&gt; Input 1&lt;/label&gt;&lt;br&gt;
&lt;input name="input2" type="text"&gt;&lt;label&gt; Input 2&lt;/label&gt;&lt;br&gt;
&lt;/div&gt;
&lt;/form&gt;
&lt;a href="#" onclick="closeSelf()"&gt;Return to main window&lt;/a&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy these into files named as above and then open up form.html. Click the link to open the popup, then enter some stuff in the popup form and click the link to close the popup. The calling form should be updated.
Copy linkTweet thisAlerts:
@sam7_976authorNov 20.2004 — Thats it

?

Thank you very much.
×

Success!

Help @sam7_976 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.18,
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,
)...