SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Dec 2007
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Use Values in popup window from parent window

    This should be simple, I want to grab a value that was entered in a parent window and redisplay it in a pop up window while the parent is active. These are date values. I have searched the Internet with no luck. Someone recommended using cookies! There must be a simple way. I am on Chapter 3 DOM on Simply JavaScript and have come across the "id" function in HTML. This does not seem to work. I have used both Firefox and IE6 to test this. I copied the code from the book and it still did not work. I also added the Core library to the directory for the page load functions. No Dice. Please help.

  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)
    You can access the parent window using window.opener.

    Once you have a reference you can easily access the main page form elements using either document.forms or document.getElementById.
    Last edited by Pepejeria; Jan 2, 2008 at 06:29.

  3. #3
    SitePoint Member
    Join Date
    Dec 2007
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks I will give it a try. I was using the self.opener qualifier and that did not work. I would have been happy to get the "id" reference rewritten to the same page. I appreciate your time with this.

  4. #4
    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)
    Sorry, I just updated my entry. window.opener is used to access the main window from the popup and window.parent is used to access a parent frame (in a frameset or from an iframe).

  5. #5
    SitePoint Member
    Join Date
    Dec 2007
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks I will give it a try. I was using the self.opener qualifier and that did not work. I would have been happy to get the "id" reference rewritten to the same page. I appreciate your time with this.

  6. #6
    SitePoint Member
    Join Date
    Dec 2007
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the syntax that works:
    document.write(window.opener.document.getElementById("variable").value);
    Use the variable name from the main page and keep the quotes. Thanks for your help!


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
  •