innerHTML yielding undefined, but correct data is visible
- by Mike Dyer
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.