Re: JavaScript and PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 14, 2008 at 2:31 PM, Mário Gamito <gamito@xxxxxxxxx> 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
>
>
> So, einstein.php will be called with a parameter (satellite):
> http://portulan-online.net/einstein.php?satellite=123
>
> After that, in einstein.php, I do:
>
> $satellite = $_REQUEST['satellite'];
>
> Next thing, I need the action in the JavaScript to be, for example:
> http://portulan-online.net/template.php?id=3&satellite=123
>
> What I don't know is how to mix the "PHP variable" satellite with the image
> ID here:
> document.getElementById('image1').src = "
> http://portulan-online.net/einstein-"; + ID + ".png";
>
> I've tried putting einstein.php all inside an "echo", but the radio buttons
> and the submit button stopped working.
>
> Does anyone knows how to do this ?
>
> Any help would be appreciated.
>
> Warm Regards,
> Mário Gamito
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
document.getElementById('image1').src = "
http://portulan-online.net/einstein-"; + <?php echo $_GET['satellite']; ?> +
".png";

You could do that.  Also, I'd suggest using $_GET instead of $_REQUEST.
Request works,b ut it is very broad.  $_GET is more specific/secure.


-- 
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month. Reseller plans and
Dedicated servers available.

"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux