SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: I'm stuck...

  1. #1
    I'm a college yuppie now! sbdi's Avatar
    Join Date
    Jul 2000
    Location
    Dublin , Ireland
    Posts
    1,271
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I'm stuck...

    Hi,

    Was hoping someone could help me out here.

    Parent Page
    Code:
    <script>
    function ShowDialog()
    {
    //declare a string variable
    
    var retval="";
    
    //show modal dialog box and collect its return value
    
    retval=window.showModalDialog
    ('dialogboxhostframe.htm',window,'dialogHeight: 250px; 
    dialogWidth: 200px;
     dialogTop: 200px; 
    dialogLeft: 300px;
     edge: Raised; 
    center: Yes; 
    scroll: No;
     help: No; 
    resizable: No; 
    status: Yes; 
    unadorned: Yes;');
    
    //check if user closed the dialog 
    //without selecting any value
    
    if(retval!="" && retval!=null)
    {
    //fill the textbox with selected value
    document.getElementById('True').checked=1
    }
    }
    </script>
    Child Page
    Code:
    <script>
    function CloseWindow()
    {
    //set return value of the dialog box or dialog result
    top.returnValue=
    document.getElementById("True" ).value;
    //close the dialog window
    window.close();
    }
    </script>
    When I select the value it isnt passed to the other page. Anyone got any ideas ? I'm stumped.
    Back Again

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It may be only that in CloseWindow you're getting the 'value' property - it depends on what input type you're using. The following, using checkboxes, works in IE6 on Win98.
    Code:
    <!-- modal1.html -->
    
    <html>
    <head>
    <script>
    function ShowDialog()
    {
      var retval = window.showModalDialog('modal2.html',window,'');
      document.getElementById('True').checked = retval;
    }
    </script>
    </head>
    <body>
    <form>
    <input type='checkbox' id='True'>
    <input type='button' onclick='ShowDialog()' value='ShowDialog'>
    </form>
    </body>
    </html>
    Code:
    <!-- modal2.html -->
    
    <html>
    <head>
    <script>
    function CloseWindow()
    {
      top.returnValue = document.getElementById("True" ).checked;
      window.close();
    }
    </script>
    </head>
    <body>
    <form>
    <input type='checkbox' id='True'>
    <input type='button' onclick='CloseWindow()' value='CloseWindow'>
    </form>
    </body>
    </html>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •