var xmlhttp; function createXMLHttpRequestObject() { var xmlHttp = this.xmlhttp; try { xmlHttp = new XMLHttpRequest(); } catch(e) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHttp"); } catch(e) { } } if (!xmlHttp) alert("Error creating the XMLHttpRequest object."); else return xmlHttp; } function populate(state) { var url = "populatetown.php?state="+state; this.xmlhttp = createXMLHttpRequestObject(); if(xmlhttp) { xmlhttp.onreadystatechange = stateChangeHandeler; xmlhttp.open("GET", url ,true); xmlhttp.send(null); } } function stateChangeHandeler() { if(xmlhttp.readyState == 4) { if(xmlhttp.status == 200) { document.getElementById('town').innerHTML = xmlhttp.responseText; } else { alert("problem retrieving data from the server, status code: " + xmlhttp.status); } } } function populate1(state) { var url = "../populatetown_admin.php?state="+state; this.xmlhttp = createXMLHttpRequestObject(); if(xmlhttp) { xmlhttp.onreadystatechange = stateChangeHandeler1; xmlhttp.open("GET", url ,true); xmlhttp.send(null); } } function stateChangeHandeler1() { if(xmlhttp.readyState == 4) { if(xmlhttp.status == 200) { document.getElementById('town').innerHTML = xmlhttp.responseText; } else { alert("problem retrieving data from the server, status code: " + xmlhttp.status); } } }