Page 1 of 1

passing a javascript variable into a php variable??

Posted: Tue Apr 05, 2005 5:58 am
by carbine
I know its possible but I dont seem to be able to do it.
Anyone with suggestions, or an example would be greatly appreciated

Thanks

Posted: Tue Apr 05, 2005 6:03 am
by CoderGoblin
Normally you don't pass a javascript variable to php without a page reload. Remember that once a PHP script has run, no actions on it are possible via PHP without resending the page.

What I imagine you are asking can be achieved by changing form values (input fields etc) using javascript and submitting the form so PHP can read it as a GET or POST variable and process it as required.

Note: The gap between Javascript and PHP is narrowing but that is definately outside the scope of this post. Example explanation (http://www.sitepoint.com/blog-post-view.php?id=191776)