I can think of two ways to do this:
Use an XMLHttpRequest object to send an asynchronous request to some PHP page which records this value.
On the php [holdvalue.php] side:
<?php
$myval = $_GET['sentval'];
// Do something with $myval
?>
On the JavaScript side:
var x = 34; //Some interesting value
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "holdvalue.php/?sentval=" + x, true);
xmlhttp.send();
OR, Use a hidden form field. On the HTML side:
<form id="sendform" method="get" action="holdvalue.php">
<input type="hidden" id="sentval" />
<input type="submit" />
</form>
And on the JS side:
document.getElementById("sentval").value = x;
// Either the following or send it whenever the user submits the form:
document.getElementById("sendform").submit();