|
Subject:
|
how to return value from modal dialog
|
|
Posted By:
|
ajaypsingh
|
Post Date:
|
5/16/2006 3:47:54 AM
|
how can i return value from a modal dialog. It doesnt return anything when i do window.returnValue='somevalue' just before window.close().
Logically it should work but practically it doesnt.
i have written the code with which the new page is to be displayed rather than giving the address of the page.(i badly need to do it this way)
window.showModaldialog("javascript:'<html>.....</html>'");
|
|
Reply By:
|
interrupt
|
Reply Date:
|
5/16/2006 4:47:57 AM
|
Hi Ajay
Can't you pass the value you want into a hidden field on your main page? If you close a browser window all variables that relate to that window are cleared, so you need to pass the value BEFORE you close it.
Hope that helps Joe
|
|
Reply By:
|
ajaypsingh
|
Reply Date:
|
5/16/2006 5:14:45 AM
|
Hi Joe,
Thanks a lot for replying, but i am still confused how will i go about setting a value in the hidden field. My sample code is below, i tried to set value in the text field 'retvalA'( i ve removed that code now) but was not able to access it in modal dialog's javascript funtion.
<HTML> <HEAD> <script language="javascript"> function OpenChild() { var ParmA1 = f1.retvalA.value;
var WinSettings = "center:yes;resizable:no;dialogHeight:300px;dialogWidth:700px;html:hello"
var titl="<TITLE>Child Webform</TITLE> ";
var scrst="<scr";
var scrend="ipt>";
var js= scrst + "ipt language=\"javascript\">" +" function Done() { " + " var ParmA = tbParamA.value;" +" window.returnValue = ParmA; " +" alert(\"ParamA=\" + window.returnValue); " +" window.close();" +" } " +" function Exit() { " +" window.close(); " +" } " +" </scr" + scrend;
var bdy= "This is just for testing. Your name is " + ParmA1 +"<P> <INPUT id=\"tbParamA\" TYPE=\"text\" size=30 value=\"this the original value\"></P>" +" <TABLE width=200 >" +" <TR>" +" <TD width=50%><BUTTON size=100 onclick=\"Done()\" type=\"button\"> OK </BUTTON></TD>" +" <TD width=50%><BUTTON size=100 onclick=\"Exit()\" type=\"button\"> CANCEL </BUTTON></TD>" +" </TR>" +" </TABLE>";
var pg="javascript:'<html><head>" + titl + js + "</head><body> "+ bdy +" </body></html>'";
var MyArgs = window.showModalDialog(pg,'',WinSettings);
if (MyArgs == null) { window.alert( "Nothing returned from child. No changes made to input boxes") } else { retvalA.value=MyArgs; } } </script> </HEAD> <body> <form name="f1"> <P><INPUT type="text" name="retvalA" value="AAA"></P>
<P><BUTTON type="button" onclick="OpenChild()"> Open Child Window</BUTTON> </P> </form> </body> </HTML>
|