Google 网上论坛不再支持新的 Usenet 帖子或订阅项。历史内容仍可供查看。

Retrieving values from dialog box

已查看 735 次
跳至第一个未读帖子

Matthew Gertner

未读,
2005年3月21日 14:31:292005/3/21
收件人
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

未读,
2005年3月21日 17:03:172005/3/21
收件人
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

未读,
2005年3月22日 05:08:002005/3/22
收件人
Cool, that seems to work. Thanks for your help.

0 个新帖子