View Full Version : i want to assign var from javascript to php
e3saaar
07-31-2003, 06:27 PM
hi
pleasee can any boody help me
i want ot assign variable from java script to php
like this
$php_var = java_var
how can i do it ?
can any boody help me please :)
:)
CrAzYCoDeR969
07-31-2003, 06:36 PM
you would have to send the JS var through a get or post request, you can probly use a hidden field, then just access the name of the field through PHP with $_GET or $_POST.
If you want to do it while the document is opened in the browser you can't.
All PHP Scripts are executed before the html code is sent to the browser.
If you want to pass the js var to another page to have the variable there for the php script, you can do it submitting with a form or just with a link.
A link submitting a variable:
<script>
document.write("<a href=\"destination.php?variable="+js_var+"\">link</a>");
</script>
Redirecting a page submitting a variable:
<script>
location.href="destination.php?variable="+js_var;
</script>
Saludo
piz
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.