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!

Passing data from parent to child window

Status
Not open for further replies.

sarahnice

Technical User
Nov 18, 2002
101
IE
Hi,
I have a html page with a standard form on it. The form contains some hidden fields and some visible data. None of the data on this page is editable. When the user click on an link beside a particular field, a child window opens. I would like to know how to retrieve the data in the hidden field of the parent window and display them in the text fields of the child window.

Any help would be greatly appreciated
Thank you
 
First of all the domain of the child and parent have to be the same. you cannot run javascript acros domains.

In the child window (popup window):
window.opener.document.getElementById('id of the hidden box').value

In the parent window:
objWindow = window.open(...
objWindow.document.getElementById('id as string' + intCounter).value

In the parent window example I used intCounter, with getElementById you pass the id as string. If you have a lot of hidden boxes all named hid1, hid2, hid3, hid4... you can loop through them.
 
you can also use the
Code:
window.showModalDialog
and
Code:
window.showModelessDialog
functions to open your child window as they accept openning arguments than can be retrieved in child window by
Code:
window.dialogArguments
method. My advice : concatenate all your parameters separating them with pipes (|) or other non usual chars before opening and then use split in child to get them. Water is not bad as long as it stays out human body ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top