Hi, this is my first post – so hello. I’m a long time member of evolt.org’s “thelist” but I wanted a forum specifically for JS and this looks good.
Anway, my problem is this:
I have a table of data that is styled with various background colors. Any one cell can be one of 5 colors – 2 shades of yellow, 2 shades of green or black.
I have a function where you rollover the row, I highlight that row so it is more easily readable.
PROBLEM: Highlighting the row is easy, returning each cell back to its’ one of 5 colors is not so easy. This is what I want to do.
Here is my highlight function (which is set via an init() function
during onload):
[code=php]
function HLRow()
{
var table = document.getElementById(“schedTable”);
var oRows = table.getElementsByTagName(“TR”);
var lastRowClass;
for(var i=0; i<oRows.length; i++)
{
oRows[i].onmouseover = function() {
BoldRow_HLCells(this);
this.style.fontWeight = “bold”;
this.style.color = “#cc0000”;
}
oRows[i].onmouseout = function() {
BoldRow_ResetCells(this);
this.style.fontWeight = “normal”;
this.style.color = “#000”;
}
}
}
You can see I am calling 2 other functions within, one to highlight the row, one to reset the row back to its colors – that’s where I need the help. Those two functions are nearly identical:
[code=php]
var classArray = new Array();
function BoldRow_HLCells (oRow) {
var oCells = oRow.getElementsByTagName(“TD”);
for(var i=0; i<oCells.length; i++)
{
classArray[i] = oCells[i].className;
oCells[i].style.backgroundColor=”#ccffcc”;
}
}
function BoldRow_ResetCells (oRow) {
var oCells = oRow.getElementsByTagName(“TD”);
for(var i=0; i<oCells.length; i++)
{
oCells[i].className = classArray[i]; // doesn’t work!
}
}
The problem is trying to go back and RESET them based on the values of my array (values which test as correct) doesn’t work. For some reason resetting the className is not working in either IE6 or NS7. Why the array value for the class does not get assigned is beyond me. I’ve done this in many other variations before with no problem, and it is certainly supported. But I have heard that className can get quirky.
So how do I set my values for the TDs back to the originals?
You can see the page in its full glory at:
[url]http://www.pixelmech.com/review/newWorkerTable.html
TIA
Tom