window.onload = function(e){
cells = document.getElementsByName('assetID');
for(j = 0; j < cells.length; j++) cells[j].style.display = 'none';
cellsBMPartNo = document.getElementsByName('BMPartNo');
for(j = 0; j < cellsBMPartNo.length; j++) cellsBMPartNo[j].style.display = 'none';
defaultAssetTableValues();
}
I am simply hiding table rows by name.
See line 2 and 4 .
It works fine in Firefox but does not in IE.
Am I missing something ?
IE does not see elements added to the document dynamically (through the DOM) with
getElementsByName. Are your elements created that way?There are other problems with that method in different versions of IE. As a workaround, you could use
getElementsByTagName('td')and then check to see if thenameattribute matches the one you are looking for in a for-loop, iterating through the array of elements.Here’s a “IE-fixed” version of
getElementsByName:And you would use it like so (for elements in table cells with name ‘assetID’):