You'll need to use Ajax. When the alert function is triggered, you can call an event that calls a PHP page on the server. You can put whatever variables you want in the URL so, for example, you could record which user ran out of time.
Add this code to your JS:
function xmlhttpPost(strURL) {
var xmlHttpReq = false;
var self = this;
// Mozilla/Safari
if (window.XMLHttpRequest) {
self.xmlHttpReq = new XMLHttpRequest();
}
// IE
else if (window.ActiveXObject) {
self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
}
self.xmlHttpReq.open('POST', strURL, true);
self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
self.xmlHttpReq.onreadystatechange = function() {
if (self.xmlHttpReq.readyState == 4) {
updatepage(self.xmlHttpReq.responseText);
}
}
self.xmlHttpReq.send('userid=1');
}
To call the function (before you display the alert box) do this:
xmlhttpPost('record_data.php');
That will hit a page called record_data.php on your site. When you build that JS, use PHP to replace the last line with the user's ID#. It will get passed in the URL to the server. (Actually, I think it's done as a post so it gets posted in the request to the server.)