I am trying to do a basic if/else statement to display or hide content within a table. It’s also important to note that this content is being fed from an XML document. I am looking for an XML tag called .
I have the following code and cannot figure out how to make this work. Whatever I try, it displays nothing on the page. My logic seems right, but I’m also not a great script writer; so any guidance would be greatly appreciated. Thank you for your time and help.
n = xmlDoc.getElementsByTagName("note")[0].childNodes[0].nodeValue
if (n != NONE){
document.write("<tr>");
document.write("<td colspan='4' id='notation'>");
document.write(y[j].getElementsByTagName("note")[0].childNodes[0].nodeValue);
document.write("</td>");
document.write("</tr>");
}else{
document.getElementsByTagName("note").style.display = 'none';
}
}
….or what if I toggle the visibility of a div on and off?:
if (none != NONE){
document.write("<div id='test' style='background-color: #999;'>")
document.write(y[j].getElementsByTagName("note")[0].childNodes[0].nodeValue);
document.write("</div>");
}else{
document.getElementById('test').style.display = 'none';
}
For those interested, my condition was incorrect. It should have been something like this: