Is it possible to change the value of a variable using an event?

Hello all. Well the topic pretty much sums up the problem. I’m pretty familiar with using events to alter the value of an html tag or attribute via the DOM. I was wondering if it is possible to use an event to alter the value of a variable within. Well I wrote the script below to test that and sure enough it didn’t work. So if by some chance it is possible to use events to do alter the value of a variable, how does one go about that?[php]

<?php $variable = "1"; echo "

Click here to change value to 2

"; echo $variable; ?>

[/php]

Javascript cannot directly alter the value of a PHP variable, as PHP is processed on the server - output sent to the browser, then the javascript is processed.

It is possible however to do so via an AJAX request.

Regular Javascript tutorial: http://www.switchonthecode.com/tutorials/simple-ajax-php-and-javascript
Using jQuery Library: http://api.jquery.com/jQuery.post/ or http://api.jquery.com/jQuery.get/

Sponsor our Newsletter | Privacy Policy | Terms of Service