I have a Javascript function that works in IE7, but is giving me trouble in Firefox.
JAVASCRIPT
function vehicleSelected() {
var ddlSelect = document.getElementById('ddlSelect');
var displayTable = document.getElementsByName('listTable')[0];
var strAuto = ddlSelect.options[ddlSelect.selectedIndex].value;
alert("ok, so far");
var rows = displayTable.getElementsByTagName("tr");
alert("this alert is not triggered");
var rowData = document.getElementById(strData);
for (var i = 0; i < rows.length; i++) {
rows[i].style.display = 'none';
}
rowData.style.display = '';
}
I am not sure how the rest of the code gets processed. Is there a universal way to toggle the display for a table row or do I need one for Firefox separate?
EDIT
<table id="listTable">
your post leaves out a lot of details, but i’m guessing your html looks something like this
nameis apparently not a valid attribute for atable(no mention here and visual studio intellisense agrees), so firefox ignores that attribute and does not find any elements namedlistTable.displayTableis undefined in the firefox execution.internet explorer however, with it’s neverending insistence for doing things wrong, sees that the
idattribute has a value of'listTable'and considers that good enough to qualify forgetElementsByName. IE does not actually consider thenameattribute you have given your table- it’s just getting lucky. removing theidattribute will cause your method to fail in IE too.