You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.4 KiB

1 year ago
function executeXhr(callback, url) {
req = false;
req = createHttpRequest();
if (req) {
req.onreadystatechange = callback;
req.open("GET", url, true);
req.send(null);
} else {
alert("Error initializing XMLHttpRequest!");
}
}
function createHttpRequest() {
var httpRequest = false;
if (window.XMLHttpRequest) { // branch for native XMLHttpRequest object
httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject) { // branch for IE/Windows ActiveX version
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
if (!httpRequest) {
httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
}
}
return httpRequest;
}
function buildOptions(xmlDoc,id) {
var selectObj = document.getElementById(id);
1 year ago
if (!selectObj || selectObj.tagName!="SELECT") {
1 year ago
return;
}
var options = xmlDoc.getElementsByTagName("option");
//clear select object
1 year ago
// for (var i = selectObj.length-1 ; i >= 0 ; i--){
// selectObj.options[i] = null;
// }
1 year ago
selectObj.length = 0;
for (var i=0; i<options.length; i++) {
var len = selectObj.length;
selectObj.length = len + 1;
1 year ago
selectObj.options[len].value = options[i].attributes[0].nodeValue;
selectObj.options[len].text = options[i].attributes[1].nodeValue;
if (options[i].attributes[2].nodeValue =="selected") {
1 year ago
selectObj.options[len].selected = true;
}
}
}