RE: [PHP] Javascript var to PHP
| From: | Jon Haworth | Date: | Wed, 18 Dec 2002 11:08:02 +0000 |
| Subject: | RE: [PHP] Javascript var to PHP | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-128686@lists.php.net to get a copy of this message | ||
Hi Cesar,
> Jon, thanx for the fast response, but the problem is
> that the link is made dynamically from a DB and the varvalue
> changes on every link... if it helps, I make this link
> list with a FOR loop in PHP and the varvalues
> I want to pass are the IDs of a table elements.
You probably need to do it along these lines:
// assume ids are in $id[1...10]
for ($i = 1; $i <= 10; $i++) {
echo '<a href="javascript:lauchinfopage(';
echo $id[$i];
echo ')">click for more info</a><br />";
}
and, in your JS function:
function launchinfopage(id)
{
url = "infopage.php?id=" + id;
// open url however you like
}
I imagine you have your url hardcoded in your launchinfopage() function...
this makes it less portable, you may want to consider passing the complete
url to a generic "open new window" function.
HTH
Jon