no creo que a una celda se le pueda asignar un nombre, en todo caso usa id="celda1"
y tampoco creo que se pueda asignar el mismo id a muchas celdas diferentes. me gustaria saber como hacerlo tambien.
edit: encontre una forma parece
Código PHP:
function cambia(hex)
{
celdas = document.getElementsByTagName('td');
for (i=0;i<celdas.length;i++)
{
if (celdas[i].id == "celda_1")
{
celdas[i].style.backgroundColor = hex;
}
}
}
Aca algo mas completo
Código PHP:
<script>
/* CODIGO FUENTE BY CARAJ0DIDA (?) :P */
var celdas = document.getElementsByTagName('td');
function mouse()
{
for (i=0;i<celdas.length;i++)
{
celdas[i].onmouseover = new Function("cambia('red','black')");
celdas[i].onmouseout = new Function("nada()");
}
}
function cambia(hex1,hex2)
{
for (i=0;i<celdas.length;i++)
{
if (celdas[i].id == "celda_1")
{
celdas[i].style.backgroundColor = hex1;
}
if (celdas[i].id == "celda_378")
{
celdas[i].style.backgroundColor = hex2;
}
}
}
function nada()
{
for (i=0;i<celdas.length;i++)
{
celdas[i].style.backgroundColor = '';
}
}
setTimeout("mouse()",1)