RE: [PHP] Javascript var to PHP

From: Date: Wed, 18 Dec 2002 11:28:35 +0000
Subject: RE: [PHP] Javascript var to PHP
Groups: php.general 
Request: Send a blank email to php-general+get-128691@lists.php.net to get a copy of this message
Actually Jon, the IDs are not exactly expressed that way, but your example gave me a nice idea... To tell you the truth (and now that I have a clearer idea of what to do), the id I need to pass along is from a random quote (or FAQ) but I'll fetch it before script is being declared (even before the HTML tag) and then target the script to a moreinfo.php?var=varvalue page... (does that make any sense?) thanks a lot. Cesar L. Aracena icaam@icaam.com.ar caracena@infovia.com.ar (0299) 156-356688 Neuquén (8300) Capital Argentina -----Mensaje original----- De: Jon Haworth [mailto:jhaworth@witanjardine.co.uk] Enviado el: miércoles, 18 de diciembre de 2002 8:08 Para: 'Cesar Aracena'; 'Php-General@Lists. Php. Net' Asunto: RE: [PHP] Javascript var to PHP 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

« previous php.general (#128691) next »