function getHTTPObject() { var xmlhttp; if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); if (!xmlhttp) { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } } return xmlhttp; } var xmlHttp = getHTTPObject(); function checkStock(stockIds) { var url = "/checkstock_ajax.php?stockId=" + escape(stockIds); xmlHttp.open("GET", url, true); xmlHttp.onreadystatechange = alertOnStock; xmlHttp.send(null); } function checkBasketStock(stockIds) { var url = "/checkstock_ajax.php?stockId=" + escape(stockIds); xmlHttp.open("GET", url, true); xmlHttp.onreadystatechange = alertOnBasketStock; xmlHttp.send(null); } function alertOnStock() { if (xmlHttp.readyState == 4) { var tool = xmlHttp.responseText; stocks = tool.split('*-*'); for(loop=0;loop parseInt(indStock[1])) { alert(indStock[2]+'\n\nSorry, we currently only have '+indStock[1]+' of this item in stock - your basket has been updated accordingly'); break; } } } } } function alertOnBasketStock() { if (xmlHttp.readyState == 4) { var tool = xmlHttp.responseText; stocks = tool.split('*-*'); for(loop=0;loop parseInt(indStock[1])) { document.getElementById('qty['+indStock[0]+']').value = indStock[1]; //reset the stock alert(indStock[2]+'\n\nSorry, we currently only have '+indStock[1]+' of this item in stock - your basket has been updated accordingly'); } } } document.frmBasket.submit(); } } function checkStockFromKeyPress(e,stockid) { var keynum if(window.event) // IE { keynum = e.keyCode if (keynum == 10 || keynum == 13) { checkBasketStock(stockid); return false; } } }