I was referring to the suer contributed notes posted on that page, specifically the following:
User Contributed Notes
fdf_set_javascript_action
DHARM_SHANKAR at REDIFFMAIL dot COM
01-Jul-2002 07:03
HOW WE ACCESS javascript variable in php code.
bsreddy_m at yahoo dot com
08-Aug-2002 12:46
How to access JavaScript variables in PHP code:
It appears that there is no straight forward way of doing this. I have come out with a small trick to acomplish this as shown below.
Save the following code as test.php and run it.
<html>
<body>
<?php
$php_var = 1;
echo "Original value: $php_var";
if(isset($form_var) && !empty($form_var))
{
$php_var = $form_var;
echo "
After receiving value from JS variable: $php_var";
}
else
{
?>
<form action="test.php" method="post" name="form1">
<input type="Hidden" name="form_var">
</form>
<script language="JavaScript">
var js_var = 5;
document.form1.form_var.value = js_var;
document.form1.submit();
</script>
<?
}
?>
</body>
</html>
The output will be:
Original value: 1
After receiving value from JS variable: 5