php & javascript

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
User avatar
dheeraj
Forum Commoner
Posts: 40
Joined: Fri Feb 06, 2009 11:54 am

php & javascript

Post by dheeraj »

hello guys, i had just totally sink to the problem of initializing value of one javascript variable to php variable....

Suppose, i have a form element having id toy, & i get its value as follows...

Code: Select all

var toy=document.getElementById("toy").value
now i want to assign the value of toy to any of php variable, but i m unable to do it,plz anyone help..

thanks
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: php & javascript

Post by papa »

You can't unless you send the variable to another page or reload the page with a form.

The php code is rendered before javascript.
Post Reply