SV: [thelist] JavaScript: How to save/return state on group of objects

Marcus Andersson marcan at home.se
Thu Nov 13 17:13:00 CST 2003


>This all works, but of course returning the cells to white is not what
I want :). My first thought was to save each cell's original value in an
array, then run through that array and reset them all. I'm just
wondering if there is a better way.

Well, arrays can be quite handy.

>I can almost see Marcus now typing up an OO answer...;)

I could, if you want...
But, even if you create an OO solution to this there will in the end
(hidden somewhere in the OO stuff) be an array :). And I also guess that
OO shouldn't be used everywhere. Your script is pretty small and simple
and I think it would make it a little bit more complex if you make it OO
(not very much though). But, if you're going to use it all over the
place I would definitely make it a class somehow.

>You can see the page in its full glory at:

>http://www.pixelmech.com/review/newWorkerTable.html

Hmmm... It doesn't work. Everything gets green. A change on row 84 to:
oCells[i].style.backgroundColor = "";
made it work

Yeay, I know it's kind of ugly and not completely DOMish to "reset" an
attribute like that, but all (not many at all according to PPK and his
quirksmode) browsers doesn't support removal of attributes. And it works
;)

/Marcus



More information about the thelist mailing list