how can i asign javascript variable to 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
B.Murali Krishna
Forum Commoner
Posts: 28
Joined: Fri May 12, 2006 2:05 am
Location: Hyderabad,India
Contact:

how can i asign javascript variable to a php variable

Post by B.Murali Krishna »

hello every body,
i have prob. of asigning javascript variable to php variable in side javascript function,
ie, i have a javascript variable like JavaScriptVar,
then how can i asign this variable to php variable, $phpvariable

like;

$phpvariable=JavascriptVar;

please give me suggestion,
regards
murali
User avatar
xpgeek
Forum Contributor
Posts: 146
Joined: Mon May 22, 2006 1:45 am
Location: Kyiv, Ukraine
Contact:

Post by xpgeek »

You don't have to want this.

PHP script get data from EGPCS variables, e.g.(GET/POST/...).

You can put js variable into url or into hidden fields of form.

Code: Select all

<script>
//......
var url = "http://somehost.com/myscript.php?myphpvar="+myjsvar;
window.location=url;
</script>
B.Murali Krishna
Forum Commoner
Posts: 28
Joined: Fri May 12, 2006 2:05 am
Location: Hyderabad,India
Contact:

Post by B.Murali Krishna »

xpgeek wrote:You don't have to want this.

PHP script get data from EGPCS variables, e.g.(GET/POST/...).

You can put js variable into url or into hidden fields of form.

Code: Select all

<script>
//......
var url = "http://somehost.com/myscript.php?myphpvar="+myjsvar;
window.location=url;
</script>

No, i dont mean that, i need to asign the variable there only, inside the function, for furthur, application
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

There is no way to directly assign a javascript variable to a php variable. Javascript is just part of php's output. You would need to pass it via one of the methods already suggested.
Post Reply