Re: Onclick event and PHP function

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

 



Hello,

Your getting confused between server side and client side.

PHP CANNOT be run on the client side which is what Javascript is.

In this case all you are doing is calling that php function twice one for
eng and once for fre.

Instead try using mydomain.com/setlang?=eng as a link which calls
vardef($lg) and then return the user to the original page.

Cheers
Richard


On Wed, February 15, 2006 10:17 am, Alain Roger wrote:
> Hi,
>
> I have some link on which if user click, should do the following things:
>
> - open a particular page
> - setup to sessions some particular variable value
>
> however, PHP function should be declared before HTML headers.
>
> so i was thinking about something like that
>
> <?php
>    function vardef($lg)
>    {
>      ... store lg to my session variables ...
>    }
> ?>
>
> <HTML>
> ...
> <A Href="none" Onclick="<?php vardef("eng") ?>">english</A>
> <A Href="none" Onclick="<?php vardef("fre") ?>">french</A>
> ...
> </HTML>
>
> but this does not work because my session variable is always setup to the
> last value (in this case "fre"), even if i click only on english :-(
>
> could you help me with this PHP issue ?
> thanks a lot,
>
> Alain
>


--
Richard Collyer
richard@xxxxxxxxxxxxxx

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[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