Re: JavaScript and PHP

From: Date: Wed, 14 May 2008 20:20:55 +0000
Subject: Re: JavaScript and PHP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-274329@lists.php.net to get a copy of this message
At 7:31 PM +0100 5/14/08, Mário Gamito wrote:
Hi, I have this HTML/JS page that switches images clicking on the radio buttons and call template.php with the image ID as parameter: http://portulan-online.net/einstein.html Now, I need to make it a PHP page, because it is going to receive a parameter from the URL that calls it and pass it as is to template.php
Mário: The key here to remember is that javascript uses ID and php uses NAME for inputs. So, if you put your variables in that form and they will work between javascript and php. Such as: <input type="radio" name="rad" id="rad" value="2" onclick="javascript:GetImage(this);">Einstein 2 Note the change of "this" in your js call -- you can do that and not have to provide the number. Also put in an action="whatever" into your form and collect the selection via $_POST['rad']; That will do what you want. Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com

« previous php.general (#274329) next »