SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    May 2004
    Location
    Midlands, UK
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    passing variables from a popup to main window

    I have two PHP scripts. The popup script (calendar.php) is linked from the main navigation of the website. When it is clicked, the calendar popups up and the dates are linked. For example; the 24th July 2004 would read: events.php?day=24&month=7&year=2004

    However, I require this information to be passed back to the MAIN window so that it can be displayed in a full screen.

    Anybody got suggestions?

    Thanks.

  2. #2
    SitePoint Enthusiast yjgx007's Avatar
    Join Date
    Jul 2004
    Location
    China or Singapore?
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    presume in main PHP scripts events.php have a HTML tag <div id=info></div> to show information which's passed back.
    below codes add to your calendar.php
    function "fnMainChange" is invoked when calendar's date have been changed!
    <script language=Javascript>
    function fnMainChange(ymd)
    {
    window.opener.document.all("info").innerText = ymd;
    }
    </script>

  3. #3
    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)
    Here's an older demo, but might be helpful

  4. #4
    SitePoint Member
    Join Date
    May 2004
    Location
    Midlands, UK
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the replies. This is not the bit that I'm struggling with. I don't know how to close the popup window and reload the main window with these variables attached. Any ideas?

  5. #5
    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)
    Here's another guess. From the child window, do something like this...
    Code:
    var p = window.opener; // parent window
    if (p) {
      p.location.href = "events.php?day=24&month=7&year=2004";
    }
    window.close();

  6. #6
    SitePoint Member
    Join Date
    May 2004
    Location
    Midlands, UK
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Mike,

    Thanks for your help. I have managed to obtain what I required with modification of your code.

    Regards,

    Adam

  7. #7
    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)
    Great.

    Have a nice day


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
  •