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

How can I pass Javascript array object to child window

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi freinds,

Through my client side applet I connect to Reuters server
and retreive Stock names. From this applet I call
javascript function and load all these Stock names into
javascript array. Now I need to open a child window which
should get populated with these stock names. Imean pass this javascript array to the child window to populate the stock names in a drop down select box.

Can any one please help me how to do this.

Thanks lot in advance,

Serene
 
ok, on you main page with the applet, include the following code:

<head>
...
<script language=javascript>
var poploaded = false // notifies this window when popup has loaded
function LoadArray() {
var myarr = new Array // this will be your stock array
myarr[0] = &quot;stock 1&quot;
myarr[1] = &quot;stock 2&quot;
myarr[2] = &quot;stock 3&quot;
var popup = window.open(&quot;popup.htm&quot;,&quot;Stocks&quot;,&quot;height=200,width=200,menubar=no,toolbar=no,scrollbars=no,statusbar=no&quot;) //open the popup
do {} // dont call any scripts in popup until that window has notified this window
while (poploaded = false)
popup.LoadData(myarr)
}
//called by popup window to notify this window that it has loaded
function NotifyLoad()
{
poploaded = true;
}
//called by popup window to notify this window that it has unloaded
</script>

...

</head>

add the following to the body tag:
<body onload=&quot;LoadArray()&quot;>
...
</body>



on your popup window (popup.htm) add the following code:

<html>
<head>
</head>
<body onload=&quot;opener.NotifyLoad()&quot;>
<script language=javascript>
var optionstring=&quot;<select name=Stock>&quot;;
var arrStock = new Array();
function LoadData(arrdata)
{
for (var i=0;i<(arrdata.length);i++){
optionstring+=&quot;<option value='&quot;+arrdata+&quot;'>&quot;+arrdata;
}
optionstring+=&quot;<\/select>&quot;;
stocks.innerHTML=optionstring
}
</script>
<div id=&quot;stocks&quot;></div>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top