Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 16th, 2006, 03:47 AM
Registered User
 
Join Date: May 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to return value from modal dialog

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>'");


 
Old May 16th, 2006, 04:47 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

 
Old May 16th, 2006, 05:14 AM
Registered User
 
Join Date: May 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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;dialog Width: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>&nbsp;&nbsp;<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\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;OK&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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>






Similar Threads
Thread Thread Starter Forum Replies Last Post
Any Expert: tested Modal Dialog on Safari? itHighway Classic ASP Basics 1 May 18th, 2005 11:54 AM
Modal Dialog window Problem anandham Javascript 7 February 16th, 2005 06:08 PM
Scrolling modal dialog to top gp_mk HTML Code Clinic 3 September 15th, 2004 07:04 AM
Modal dialog window eldanh ASP.NET 1.0 and 1.1 Basics 0 August 10th, 2004 02:07 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.