Hi,
I am a JS newbie. Hopefully the answer to my question is not trivial.
I have written a simple webpage that presents a table. A JS function
allows the viewer to click on a cell and each cell with the same
content has the background color changed to lime green. Each cell that
was previously highlighted has the background color changed back to
white. This works great with Firefox but does not work correctly with
IE. In IE, none of the previously highlighted cells has the background
color changed back to white. How can I modify the syntax so that it
will work in both browsers? Below is the JS function. A simple
webpage that will demonstrate the problem is at
http://uia.dyndns.org/test.html
Thanks for any help. Thanks also to Martin Honnen! His posts showed
me how this could be done.
Lance
<script type="text/javascript">
// Script for traversing all of the cells in all of the tables in the
document
function highlight_cell (element) {
var allTables = document.getElementsByTagName('TABLE');
var save_cell_contents=element.innerHTML
for (var i=0; i<allTables.length; i++){
table=allTables[i]
for (var row_index = 0; row_index < table.rows.length;
row_index++) {
for (var c=0; c < table.rows[row_index].cells.length; c++){
if(table.rows[row_index].cells[c].innerHTML==save_cell_contents){
table.rows[row_index].cells[c].bgColor='lime';
}
else
if(table.rows[row_index].cells[c].bgColor=='lime')
table.rows[row_index].cells[c].bgColor='white';
}
}
}
}
</script>