/*AJAX code for updating list of Districts*/
/*Get the HTTP Object*/
function getHTTPObject(){
if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
else if (window.XMLHttpRequest) return new XMLHttpRequest();
else {
alert("Your browser does not support AJAX.");
return null;
}
} /*Change the value of the District selection list*/
function setOutput(){
if(httpObject.readyState == 4){
/*delete all the old items*/
var sel = document.getElementById("District");
for (var i=(sel.options.length-1); i>=0; i--){
var option=sel.options[i];
sel.options[i] = null;
}
/*add the new items*/
responseString = httpObject.responseText;
/*split this string into each district, which are seperated by a comma*/
var districts = new Array();
districts = responseString.split(',');
for(var i=0; i<districts.length; i++){
sel.options.add(new Option(districts[i], districts[i]));
}
}
}
/*Implement business logic to update the list of districts to match the region that has been selected*/
function updateListOfDistricts(){ httpObject = getHTTPObject();
if (httpObject != null) {
var combo1 = document.getElementById("Region");
var dropdownValue = combo1.options[combo1.selectedIndex].text
httpObject.open("GET", "getdistrict.php?selectedRegion="
+dropdownValue+"&dummy=" + new Date().getTime(), true);
httpObject.send(null);
httpObject.onreadystatechange = setOutput;
}
}
var httpObject = null;
