SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Popup with dynamic content

    It's late and I'm running out of ideas...

    Here's the scenario. Page_A has a number of links like this: 'newpage.php?id=x'
    The only thing that changes in each link is the number 'x'. Once clicked, 'newpage.php' uses 'x' to search a DB (mySQL) and displays the data. So far no problem at all... What I don't like is the NEW page... What I would like to do is create a (user-requested!) popup: once a link in Page_A is clicked, a popup window should show the data referring to 'x'... How does one do this?... I mean, I can create the popup in Javascript, no problem here - but how do I pass the 'x' along, fish out the data in the DB, and display that?... I have a feeling the old brain need a rest, so I'll leave this request here for the smart ones out there.

    Thanks for all the feedback.

  2. #2
    I Never Give Up roosevelt's Avatar
    Join Date
    May 2005
    Posts
    515
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hehe I don't know why pop-up would be a good idea... but its suitable for tool tips and such. But anyways all you have to do is make two files. Called newpage.php and data.php.

    Paste this javascript code before the </head> tag:

    Code:
    <script language="javascript" type="text/javascript">
    <!--
    function popitup(url) {
    	newwindow=window.open(url,'name','height=200,width=150');
    	if (window.focus) {newwindow.focus()}
    	return false;
    }
    
    // -->
    </script>
    Now in the newpage.php generate your file list, and those links. But change those links to something like:

    Code:
    <a href='javascript:void(null);' onclick="popitup('data.php?id={$data['x']}')">Page Title</a>
    What will happen is the little javascript will open data.php file with that id parameter in a pop-up window .

    In the URL code i assume $data['x'] is a variable from the db.

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. That seems to do just the trick.

  4. #4
    SitePoint Member
    Join Date
    Mar 2007
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your post helped me to solve my problem.
    Thank you!

  5. #5
    SitePoint Zealot
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    199
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great! That's what forums are for.


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
  •