Agree with markkuk
You may use AJAX or have to post the data from your javascript so that the server side PHP will pick it up something similar to this..
create a file called test.php
and try the following code and it may give you a solution
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="JavaScript">
function Test(num)
{
window.location.href = "test.php?myval=" + num;
}
</script>
</head>
<body>
<p><input type="button" value="Test Java script!" onClick="Test(100);" ></p>
";
}
?>
</body>
</html>