Got this code, which works fine in FF3 - it dynamically redraws a menu
from user input.
####
function so_clearInnerHTML(obj) {
// so long as obj has children, remove them
while(obj.firstChild) obj.removeChild(obj.firstChild);
} - this just for info - ignore that there is no function around the next
bit!
if (httpRequest.status == 200) {
var xmldoc = httpRequest.responseXML;
//var objNodeList;
//objNodeList = xmldoc.getElementsByTagName
('systemname');
so_clearInnerHTML(document.getElementById
("systemslist"));
// loop through the returned xml list for entries and
append them back to the div
var x = 0;
while (xmldoc.getElementsByTagName('systemname')[x]) {
//alert('counted['+i+']');
var sysname = xmldoc.getElementsByTagName
('systemname')[x].childNodes[0].nodeValue;
var sysid = xmldoc.getElementsByTagName('systemid')
[x].childNodes[0].nodeValue;
//alert('systemname['+sysname+']');
//alert('systemid['+sysid+']');
// create a DIV element, using the variable eLink as
a reference to it
eLink = document.createElement("a");
//use the setAttribute method to assign it an id
eLink.setAttribute("href","findsystem.asp?
systemid="+sysid);
// add the text from 'systemname' to the anchor
element
eLink.appendChild(document.createTextNode
(xmldoc.getElementsByTagName('systemname')[x].childNodes[0].nodeValue));
// append your newly created element to an already
existing element.
document.getElementById("systemslist").appendChild
(eLink);
eBreak = document.createElement("br");
document.getElementById("systemslist").appendChild
(eBreak);
x++;
}
} else {
alert('There was a problem with the request.');
}
####
doesn't repopulate the menu via IE6 or 7
I tried to switch the while to a for -
##
for (var i=0; i<objNodeList.length; i++) {
##
(ignore the x switch in i)
but that returns a zero length list of nodes for IE, and still works for
FF
is there another way for IE to see the existance of the node list, or do
I need to approach the looping some other way?