How to send value from child window to parent window.

Discussion in 'JavaScript' started by Subikar, Jul 19, 2007.

  1. #1
    Suppose I opened a popup from parent window I have calculated some calculation on child window while submitting the value from child window I need to close the child window and display the calculated value of child window to parent window textbox.


    Thanks in advance for any help,

    Subikar
     
    Subikar, Jul 19, 2007 IP
  2. it career

    it career Notable Member

    Messages:
    3,562
    Likes Received:
    155
    Best Answers:
    0
    Trophy Points:
    270
    #2
    Use cookie.
     
    it career, Jul 19, 2007 IP
  3. samusexu

    samusexu Well-Known Member

    Messages:
    138
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #3
    Use the window.opener property to gain acces to a field in the parent window from the child window.
     
    samusexu, Jul 19, 2007 IP
  4. DavidAusman

    DavidAusman Peon

    Messages:
    399
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #4
    On the first page it may looks something like

    
    var newWin = window.open("additional @param here");
    
    PHP:
    On the second page
    
    function _closeWin(valueToBeParsed) {
    var parentWin = window.opener;
    
    // If you have a specific target element, specify it here
    var obj = document.getElementById("where");
    
    parentWin.obj.value = valueToBeParsed;
    
    parentWin.focus();
    this.window.close();
    }
    
    PHP:
     
    DavidAusman, Jul 19, 2007 IP
  5. in2clearsky

    in2clearsky Peon

    Messages:
    121
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    In child window you can use below code to assign value back to parent text box.

    window.opener.document.form.textbox.value='xxx';
    self.close();

     
    in2clearsky, Jul 24, 2007 IP