Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 16th, 2006, 03:47 AM
Registered User
Join Date: May 2006
Location: new delhi, delhi, India.
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)


Reply With Quote
  #2 (permalink)  
Old May 16th, 2006, 04:47 AM
Friend of Wrox
Join Date: May 2004
Location: , , .
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts

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

Reply With Quote
  #3 (permalink)  
Old May 16th, 2006, 05:14 AM
Registered User
Join Date: May 2006
Location: new delhi, delhi, India.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

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.

       <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)
          "Nothing returned from child. No changes made to input boxes")
  <form name="f1">
   <P><INPUT type="text" name="retvalA" value="AAA"></P>

   <P><BUTTON type="button" onclick="OpenChild()">
       Open Child Window</BUTTON>

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 08:14 AM.

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