passing a javascript variable into a php variable??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
carbine
Forum Newbie
Posts: 6
Joined: Mon Mar 14, 2005 6:37 am

passing a javascript variable into a php variable??

Post 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
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post 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)
Post Reply