in order to javascript to pass variables to PHP, the variables must either be put into a form and submitted via POST or GET or you can simply use javascript to call the other page with query string like this:
../filename.php?var1=value1&var2=value2
depending on which approach you use, you will find the variables defined in either $POST or $GET. if you use the query string approach i just typed, your filename.php code might look like this:
<?
echo "var1 = " . $_GET['var1'];
echo "var2 = " . $_GET['var2'];
?>