var roomslist = new Array(148,149,150,102,103,105,106,109,112,139,118,135,129,127,126,121,130);
var object = new Array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
for(var i = 0; i < roomslist.length; i++){
var url = "fillmap.php?office=" + roomslist[i];
if(page){
page.open("GET",url);
page.onreadystatechange = function() {
if(page.readyState == 4 && page.status == 200) {
object[i] = page.responseText;
}
}
page.send(null); // #1--IF THIS REMAINS, CODE EXECUTES PERFECT
alert(object[i]);
document.getElementById(roomslist[i]).setAttribute("bgcolor",object[i]);
//alert(object[i]); // IF THIS REMAINS AND #1 IS COMMENTED, EVERY ELEMENT CHANGES TO 0 (from object array)
}
}
// THIS WORKS
for(var i = 0; i < roomslist.length; i++){
if(roomschecklist[i]){
document.getElementById(roomslist[i]).setAttribute("bgcolor","00CCFF");
}
}*/
IF BOTH #1 and #2 are commented (no alerts), the code does nothing.