Page 1 of 1
Java to PHP
Posted: Mon Oct 07, 2002 7:25 am
by pbangsoe
Is there a way to get a Java script return value into a PHP variable.
I want to do something like this:
<?
echo "<SCRIPT language=JAVASCRIPT>";
echo "document.write(screen.width);"; // just for debug
echo "var sw =screen.width";
echo "</SCRIPT>";
echo $sw; // I know this is not working, but it is somehow what i want
?>
Posted: Mon Oct 07, 2002 7:41 am
by twigletmac
Please read this:
viewtopic.php?t=1030
Mac
Posted: Mon Oct 07, 2002 7:50 am
by pbangsoe

May be i am not that hard core, but i want to get a value FROM Java not the other way around.
Or am i missing something !
Posted: Mon Oct 07, 2002 7:53 am
by twigletmac
Basically PHP is server side and Javascript is client side, this means that the PHP script has finished before the Javascript starts - they do not run at the same time. So it is relatively easy to pass a variable from PHP to Javascript as the sticky says. If you want to do it the other way around you need to send the variable to the server somehow, this means that you need to set it in a cookie, in the URL's query string or post it via a form and refresh the page. You will then be able to give the PHP script access to the variable. You cannot send a variable directly from Javascript to PHP.
Mac