Entry
How can i change the bgColor of a cell with an onclick event from another cell ??
It doesn-t seem to work... http://194.102.198.74/pczoom/index.php?ce=componente&tip=placidebaza
PLEASE HELP : When the big cell is clicked the orange 1 pixel line should change it's color
Apr 18th, 2002 06:19
Russ Locke, Sorin V,
The basic answer to your question can be found in FAQTS reference:
http://www.faqts.com/knowledge_base/view.phtml/aid/4005/fid/192
Addendum:
I would suggest rearranging the (if) clauses in the following order:
The (document.getElementById) is supported by the newest browsers (IE5+
and NS6+ - let this catch first. By today's standards, this is all you
should really need.
If you want to be nice to those people who are still using older
browsers, follow up with the (document.layers) which is for NS and
(document.all) which is for IE
function setBgColor (id, color) {
if (document.getElementById)
document.getElementById(id).style.backgroundColor = color;
else if (document.layers)
document[id].bgColor = color == 'transparent' ? null : color;
else if (document.all)
document.all[id].style.backgroundColor = color;
}