if i want to pass in my value for confirmation box!!! so lets say i want to delete item no 1 so i checked the check box then when i pressed the delete button. the popup box come
The middle parameter for showModalDialog can be an object or an array or anything you like, and this passed object can be retrieved in the child form (say, in its OnLoad event) by referencing window.dialogArguments.
Hang on a second and I'll include a code sample (it's been about 10 years since I've done this).
Update: here is a very simple code sample that shows the basics of passing data back and forth between the parent and child windows using showModalDialog. Create two HTML files in the same folder, and name them "Parent.htm" and "Child.htm". Put this code in Parent.htm:
and put this code in Child.htm:
Return value:
Then open Parent.htm in a browser and click the "CustomConfirm" button. The child window will display the values set in the parent window ("some data 1" and "some data 2"), and when the child window is closed, whatever you've entered in the third text box will be displayed in an alert box called from the parent. This shows the basic way in which you pass data to the child and get data back from it.
There's also a way to return an object from the child window (which becomes the value returned from the showModalDialog call itself), but I don't recall how to do this.
Update 2: To pass an array instead, you would do something like this:
var myarray = new Array();
myarray[0] = "Bob Smith";
myarray[1] = "Doug Jones";
myarray[2] = "Englebert Humperdinck";
var ret = showModalDialog('Child.htm', myarray, '');
alert(ret); // this will display whatever the child set for its
// window.returnValue
And then in the child window, you would get the array like before and use it to build your details display:
var myarray = window.dialogArguments;
alert(myarray[0]); // or whatever
Since you're now passing in an array instead of an object, you'll need to return true or false (instead of adding a returnvalue property to the passed object). You set the return value in the child by setting the window.returnValue
property. Since you're creating a confirmation popup, you would presumably have a "Yes" and a "Cancel" button which would set window.returnValue
to true
or false
, respectively.