Reputation: 11206
Is there anyway I can pass a javascript variable to a Modal?
Upvotes: 0
Views: 3010
Reputation: 8814
Option 1:
Try this.. while opening the modaldialog send the window as the parameter
showModalDialog(url,window,params);
and in the modal window
var parWin = window.dialogArguments;
now parWin contains your parent window object.
From here you can now access all data from your parent, be it variables or methods.
Option 2:
<SCRIPT LANGUAGE="JavaScript">
<!--
var a = new Array;
a[0]="first";
a[1]="second";
a[2]="third";
// -->
</SCRIPT>
And we pass the array a to the dialog box:
window.showModelessDialog('7b.html',a);
The callee 7b.html includes the following script:
<SCRIPT LANGUAGE="JavaScript">
<!--
a = dialogArguments;
a[0] = "fourth";
// -->
</SCRIPT>
Some other reading on this:
http://www.webreference.com/js/column90/
http://www.webreference.com/js/column90/7.html
http://www.webreference.com/js/column90/8.html
Upvotes: 3