Retrieving values from dialog box

730 views
Skip to first unread message

Matthew Gertner

unread,
Mar 21, 2005, 2:31:29 PM3/21/05
to
Hi,

I am looking for the most direct way to retrieve values that have been
entered by the user into a modal dialog box. I realize that I can just
write the values to a global object or variables in the onAccept()
method, but isn't there a way to get the values directly from the
dialog box. I thought I could do something like this:

<dialog id="mydialog"
...
>
<property id="myproperty">
...
</dialog>

Then in the dialog:

function onAccept()
{
window.myproperty = "foo";
}

and in the main function:

var dlg = window.openDialog(..., "modal");
var result = dlg.myproperty;

Unfortunately, I can't find any examples of this and I haven't managed
to find the right approach by trial and error.

Neil

unread,
Mar 21, 2005, 5:03:17 PM3/21/05
to
Matthew Gertner wrote:

>var dlg = window.openDialog(..., "modal");
>var result = dlg.myproperty;
>
>

I have this nasty suspicion that the window.close of the dialog destroys
all of the global variables making it impossible to return a property.
Generally the most convenient way is to pass input and output parameters
in a JavaScript object e.g.
function showDialog(aIn) {
var params = { in: aIn, out: null };
window.openDialog(..., "modal", params);
return params.out;
}
then the dialog's script would have
var params = window.arguments[0];
var in = params.in;
etc.

--
Warning: May contain traces of nuts.

Matthew Gertner

unread,
Mar 22, 2005, 5:08:00 AM3/22/05
to
Cool, that seems to work. Thanks for your help.

Reply all
Reply to author
Forward
0 new messages