»
EnglishFrenchVietnamese

Print - Cell BG Changer - JavaScriptBank.com

Full version: jsB@nk » Form » Table » Cell BG Changer
URL: https://www.javascriptbank.com/cell-background-changer.html

Cell BG Changer © JavaScriptBank.comGive any table a 'rollover' personality with this script! Using it, you can allow the cells of any given table to change color when the mouse rolls over them. This is a very powerful script that can add a little magic to any table, whatever the table is used for.

Full version: jsB@nk » Form » Table » Cell BG Changer
URL: https://www.javascriptbank.com/cell-background-changer.html



CSS
<STYLE>TD {POSITION: relative}</STYLE><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


JavaScript
<SCRIPT language=JavaScript>// This is a cross-browser (IE5.5 & NN4.7) cell background changervar oncell = "c0"function chgColor(celno){ var chgcell if (document.layers) { //browser is NNfor (var i = 1; i < 5; i++){chgcell = "window.document.c" + i + ".bgColor='white'";eval(chgcell);}chgcell = "window.document."+ celno + ".bgColor='orange'";}else // assume IE5{for (var index =1; index < 5; index++) { clrIt = "document.getElementById('c"+ index +"').bgColor='white'"; eval(clrIt);}chgcell = "document.getElementById('"+ celno + "').bgColor='orange'";} eval(chgcell);}function overm(celno){ var chgcell if (document.layers) { // browser is NNchgcell = "window.document."+ celno + ".bgColor='yellow'";}else //assume IE{chgcell = "document.getElementById('"+ celno + "').bgColor='yellow'";} eval(chgcell);}function outm(celno){ var chgcell if (document.layers) { // browser is NNchgcell = "window.document."+ celno + ".bgColor='white'";}else //assume IE{chgcell = "document.getElementById('"+ celno + "').bgColor='white'";} eval(chgcell);}</SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<TABLE border=1>  <TBODY>  <TR>    <TD id=c1><A href="http://JavaScriptBank.com" onclick="oncell = 'c1'; chgColor('c1');" onmouseout="if (oncell != 'c1') {outm('c1');}" onmouseover="if (oncell != 'c1') {overm('c1');}">cell 1</A></TD>    <TD id=c2><A       href="http://JavaScriptBank.com"       onclick="oncell = 'c2'; chgColor('c2');"       onmouseout="if (oncell !='c2') {outm('c2');}"       onmouseover="if (oncell !='c2') {overm('c2');}">cell 2</A></TD>    <TD id=c3><A       href="http://JavaScriptBank.com"       onclick="oncell = 'c3'; chgColor('c3');"       onmouseout="if (oncell !='c3') {outm('c3');}"       onmouseover="if (oncell !='c3') {overm('c3');}">cell 3</A></TD>    <TD id=c4><A       href="http://JavaScriptBank.com"       onclick="oncell = 'c4'; chgColor('c4');"       onmouseout="if (oncell !='c4') {outm('c4');}"       onmouseover="if (oncell !='c4') {overm('c4');}">cell 4</A></TD></TR></TBODY></TABLE><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->