Forum Moderators: coopster

Message Too Old, No Replies

popup using javascript in php

         

kkrumlia

9:34 pm on May 30, 2003 (gmt 0)

10+ Year Member



Hi there

Hope everybody is feeling fine today. I have a site where various items appear as thumbnails under each a small button. When i press that button i want to go to a description page , I want that page to be a popup. I'm using javascript in php. code for that button is like this

echo "<center>$$IC&nbsp;&nbsp;<a href=\"javascript:openpopup()\"><img name=\"home\" src=\"./img/buttbuy.gif\" onmouseover=\"this.src='./img/buttbuya.gif';\" onmouseout=\"this.src='./img/buttbuy.gif';\" border=\"0\" width=\"53\" height=\"25\"></a></center>");

the openpopup function

echo "<script language=\"JavaScript\" type=\"text/javascript\">";
echo "function openpopup(){
var popurl=\"$Relative/description.php?II=$II\"
winpops=window.open(popurl,\"\",\"width=600,height=500, scrollbars, resizable\")
}";
Now this all works , But the problem is there are many thumbnails on the page all retrieved from database and for each thumbnail the $II is different so what's happening is that $II is not becoming different to each thumbnail; it only takes the last one and thus the description page comes out as lets say
http://pathto/description.php?II=16 for all thumbnails

Any ideas how to solve this , Thank you

[edited by: jatar_k at 11:27 pm (utc) on May 30, 2003]
[edit reason] fixed smiley in code [/edit]

daisho

4:29 am on May 31, 2003 (gmt 0)

10+ Year Member



have the javascript function take a parameter.

Then when you generate each link pass the parameter at that point.

ie:

echo "<center>$$IC&nbsp;&nbsp;<a href=\"javascript:openpopup($II)\"><img name=\"home\" src=\"./img/buttbuy.gif\" onmouseover=\"this.src='./img/buttbuya.gif';\" onmouseout=\"this.src='./img/buttbuy.gif';\" border=\"0\" width=\"53\" height=\"25\"></a></center>");

the openpopup function

function openpopup( id ) {
echo "<script language=\"JavaScript\" type=\"text/javascript\">";
echo "function openpopup(){
var popurl=\"$Relative/description.php?II=\".id
winpops=window.open(popurl,\"\",\"width=600,height=500, scrollbars, resizable\")
}";

[edited by: jatar_k at 6:21 pm (utc) on June 1, 2003]
[edit reason] fixed smiley [/edit]

kkrumlia

10:35 pm on Jun 1, 2003 (gmt 0)

10+ Year Member



Thanks Daisho , right on