Page 1 of 1
How to equate a php variable with a javascript var
Posted: Sun May 15, 2011 11:05 am
by m2babaey
Hi
I have some js code in my .php file
In the js code I have a variable "names"
I need to tell php the value of this variable and call it $names
How can I do that?
Thank you for your help
Re: How to equate a php variable with a javascript var
Posted: Sun May 15, 2011 1:11 pm
by getmizanur
you can use ajax..
Re: How to equate a php variable with a javascript var
Posted: Sun May 15, 2011 1:39 pm
by flying_circus
m2babaey wrote:Hi
I have some js code in my .php file
In the js code I have a variable "names"
I need to tell php the value of this variable and call it $names
How can I do that?
Thank you for your help
Short answer is, you can't without making a new page request. PHP is processed before the javascript is. Therefor you cannot drink the glass of water before you pour the glass of water. Now, you can have PHP tell javascript the value of your variable.