/    Sign up×
Community /Pin to ProfileBookmark

to pass variables from parent window to child

I have jsp file – Main.jsp as my parent window. I have pop-up window (child) to open new window . My probs is how i am going to pass variables (textfield,select,etc data) to my child window?

tq

to post a comment
JavaScript

11 Comments(s)

Copy linkTweet thisAlerts:
@CrazyMerlinJan 18.2006 — you have a misconception here, one that many people have.

you do not 'pass' data to a child window, the child window 'gets' data from it's parent

think about it that way, and it's much clearer.

to get data from a parent window, you use:
[CODE]
window.opener.document.getElementById('targetname')
[/CODE]

where targetname is the name of the value you want

example:

lets say you have a new child window with a textbox that has an id of childText, and you also have a textbox on your parent document that has an id of parentText

when you create your child window, you want the textbox on child to be the same as the textbox on parent

this would be your code in the child document
[CODE]
<script>
document.getElementById('childText').value = window.opener.document.getElementById('parentText').value;
<script>
[/CODE]
Copy linkTweet thisAlerts:
@aisyahauthorJan 18.2006 — Thanks for the reply..

I can't open new window ...

Is it correct the syntax below

window.open('AddData.jsp?a='"+document.Form.name.value+" & .......

still new ..



tq
Copy linkTweet thisAlerts:
@aisyahauthorJan 19.2006 — function test(formname){

var e = document.getElementById('no').value;

var f = document.getElementById('num').value;

window.open('AddXl.jsp?a='+e+'&b='+f+'&formname=pForm')

}

<input type=button onclick="test(this.form)">

why this doesn't work? no pop up window is open

tq

Please .. i need this asap
Copy linkTweet thisAlerts:
@CrazyMerlinJan 19.2006 — pretty much correct, but from what I can see, you actually want:

window.open('AddXl.jsp?a='+e+'&b='+f+'&formname='+formname.name);


when you send this.form in your call to test(), you are passing the form object not just the name.

you could say: <input type="button" onclick="test(this.form.name)">

and then have: window.open('AddXl.jsp?a='+e+'&b='+f+'&formname='+formname);

that would also make more sense.
Copy linkTweet thisAlerts:
@blah1985Jan 19.2006 — man this needs to be a sticky
Copy linkTweet thisAlerts:
@CrazyMerlinJan 19.2006 — tell me about it!

I remember answering a few parent-child data passing posts. lol

It's ok though aisyah, I don't mind.
Copy linkTweet thisAlerts:
@aisyahauthorJan 19.2006 — thanks ...

tried as you say

<input type=button onclick="test(this.form.name)">


but no popup window is open..

any ida
Copy linkTweet thisAlerts:
@aisyahauthorJan 20.2006 — thank all ... listen to my probs ..

i solved already ....
Copy linkTweet thisAlerts:
@ksaravananJan 23.2006 — Hi aisyah,

I am trying to pass value from parent page to child page, my stt looks like this

"window.open('Temp2.aspx?val='+txt,'calendarPopup','status=yes,toolbar=no,menubar=yes,titlebar=yes,resizable=yes,location=no,scrollbars=no');

but due to some reason this does not work.

I would appreciate if you could send me your solution.

Thanks
Copy linkTweet thisAlerts:
@CrazyMerlinJan 23.2006 — where are you getting and setting 'txt' ?
Copy linkTweet thisAlerts:
@aisyahauthorJan 24.2006 — Dear ksaravanan,

you can try below :-

window.open('Temp2.aspx?val='+document.no.value+,'calendarPopup','status=yes,toolbar=no,menubar=yes,titlebar=yes,re sizable=yes,location=no,scrollbars=no');


my problems is that I have wrong loop that's why it doesn't work ...


good luck ..

or try to post your code
×

Success!

Help @aisyah 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.19,
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,
)...