Page 1 of 1
how can i asign javascript variable to a php variable
Posted: Tue Oct 31, 2006 8:09 am
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
Posted: Tue Oct 31, 2006 8:27 am
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>
Posted: Tue Oct 31, 2006 8:32 am
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
Posted: Tue Oct 31, 2006 10:36 am
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.