Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/10/2007, 14:55
ivanillo
 
Fecha de Ingreso: octubre-2007
Mensajes: 2
Antigüedad: 16 años, 7 meses
Puntos: 0
Pregunta Valores de una fila

Hola necesito que al hacer click en una fila de una tabla, esta cambie de color (hasta aquí sin problema) y ademas me devuelva los valores de las celdas de esa tabla, con el siguiente código me funciona en IE6 y Opera pero no en Firefox. Podéis Ayudarme ???
Gracias:

CODIGO:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="contactos.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">
function selecciona(id){
if (document.getElementById){
//alert(id);
var ele=document.getElementById(id);
var filas = document.getElementsByTagName("tr");
//alert (filas.length);
for(var i=0; i<filas.length; i++) {
var fila = filas[i];
fila.style.backgroundColor = '#FFFFFF';
}
ele.style.backgroundColor = '#BBBBBB';

/*
alert(ele.childNodes[0].firstChild.nodeValue);
alert(ele.childNodes[1].firstChild.nodeValue);
alert(ele.childNodes[2].firstChild.nodeValue);
*/
for(var j=0; j < ele.childNodes.length; j++) {
//alert(j);
alert(ele.childNodes[j].firstChild.nodeValue);
}

}
}
</script>


</head>

<body class="oneColElsCtrHdr">

<div id="container">
<div id="header">
<h1>Header</h1>
<!-- end #header -->
</div>

<div id="mainContent" align="center">
<p>&nbsp;</p>
<table width="500" border="1" id="tablaid">

<tr id="tr1" onclick="selecciona('tr1')">
<td>a</td>
<td>b</td>
<td>c</td>
</tr>

<tr id="tr2" onclick="selecciona('tr2')">
<td>d</td>
<td>e</td>
<td>f</td>
</tr>

<tr id="tr3" onclick="selecciona('tr3')">
<td>g</td>
<td>h</td>
<td>i</td>
</tr>
</table>


<h1>&nbsp;</h1>
<!-- end #mainContent --></div>
<div id="footer">
<p>Footer</p>
<!-- end #footer --></div>
<!-- end #container --></div>
</body>
</html>