SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Sep 2003
    Location
    Norwich
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Passing variables between two windows

    I've searched high and low, I can't find the information I need to do this.

    Basically, I have a window with an empty text field in. When I click on a link, another window appears on top of the first. (A pop up window.)

    The popup window also has a text field in it. If I type "Test" in the popup window's text field and click "Submit", is there a way I can send that value to the empty text field in the first window?

    Any help would be appreciated!

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <script type="text/javascript">
    
    function populateOpener(oField, sOpenerFormName)
    {
        if (opener && !opener.closed && opener.document.forms[sOpenerFormName])
            opener.document.forms[sOpenerFormName].elements[oField.name].value = oField.value;
    }
    
    </script>
    .......
    .......
    <form.....onsubmit="populateOpener(foo,'myForm');self.close();return false;">
    <input type="text" name="foo" value="" />
    <input type="submit" />
    .......
    Give the pop-up field the same name ("foo" here) as the field in the opener window.
    ::: certified wild guess :::

  3. #3
    SitePoint Member
    Join Date
    Sep 2003
    Location
    Norwich
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Works great, thanks.


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
  •