innerHTML yielding undefined, but correct data is visible
Posted
by Mike Dyer
on Stack Overflow
See other posts from Stack Overflow
or by Mike Dyer
Published on 2010-06-07T21:22:10Z
Indexed on
2010/06/07
21:32 UTC
Read the original article
Hit count: 218
var Model,node;
document.getElementById('sedans').innerHTML='';
var thismodelabbr,prevmodelabbr;
for(var j=0; j<xmlDoc.getElementsByTagName('data').length; j++){
node = xmlDoc.getElementsByTagName('data')[j];
thismodelabbr=node.getAttribute('model');
if(prevmodelabbr!=thismodelabbr){
Model+='<a href="">'+ node.getAttribute('model')+'</a>';
}
prevmodelabbr=thismodelabbr;
document.getElementById('sedans').innerHTML=Model;
}
The above javascript snippet is working correctly and as needed, but I'm getting an "Undefined" response before the entry is displayed within its respective page. I'm assuming it has to do with the .innerHTML call. Any insight would be deeply appreciated.
© Stack Overflow or respective owner