SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2006
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Passing variables from pop-up window to parent window.... how?

    I have a "main window" with a edit button. It is actually a form holding entry from user.

    When edit button is clicked, a "new window" will show. The user can make changes in the new window.
    When save button is clicked, the "new window" will close and pass the changes(new value) to the "main window".
    The "main window" will will reload to show the latest update.



    i get to refresh the parent page and close the child page by javascript below...

    Code:
    function refreshParent() {
    window.opener.location.href = window.opener.location.href;
    if (window.opener.progressWindow) 
    window.opener.progressWindow.close();
    window.self.close();
    }
    however, how to pass the variables from child window to parent window???

  2. #2
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have a function in the main window that will take the variable(s)
    Code:
    function mainWindowFunction(variable) {
        // do something
    }
    Then you simply call this method from the child window before you close it
    Code:
    // from child window
    opener.mainWindowFunction(whatEverValue);


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
  •