#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Posts
    2
    Rep Power
    0

    PHP/Javascript popup Window


    Hi,
    I'm was wandering if anyone could help me out with a problem i'm having?

    I've got a page with a list of movies(a result of an sql query) and i need for visitors to be able to click on any movie and have a window pop-up with the details of that movie(details will come from sql query on new page using ?id=$id).

    I know this is probably more of a javascript problem....but i need to know how to pass the original movie ID ($id) to the Javascript, to open the new window...

    Can anyone please help??
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2000
    Location
    Denmark
    Posts
    69
    Rep Power
    18
    ok, when showing the movies on you mainpage make a link like this around the title

    PHP Code:
    <a href="javascript:winpop('$id')">$title</a
    and then make a javascript like this in your head section of your html document:

    PHP Code:
    <SCRIPT LANGUAGE="JavaScript">
    function 
    winpop(id) {
      
    window.open("/movie_info.php?id="+id,"_blank","width=300,height=400");
    }
    </SCRIPT> 
    guess you could also do something like this in every link


    PHP Code:
    <a href="javascript:window.open('/movie_info.php?id=$id','_blank','width=300,height=400')">$title</a
    now a new window is opened with this url movie_info.php?id=$id
    now you can use this id to select the thing you wanna show with you movie


    btw the javascript function window.open() holds theese values
    window.open('url', 'name', [,'width=x,height=x,location,menubar,scrollbars,status,titlebar,toolbar'])

    them last ones you can set to 0 or 1 if i remember correctly

    regards
    Simon
    I always wanted to be somebody, guess I should have been more specific
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Posts
    2
    Rep Power
    0
    Thanks for the help Simon....
    The code worked fine!!!

  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    9
    Rep Power
    0
    I am trying the same thing, except i am unsure of how to call the data in the popup from the $id string

    Any help would be great. thx.
    I know this thread is old, but its been a great help.

IMN logo majestic logo threadwatch logo seochat tools logo