Ver Mensaje Individual
  #1 (permalink)  
Antiguo 29/05/2007, 11:26
alhernandez7
 
Fecha de Ingreso: diciembre-2006
Mensajes: 50
Antigüedad: 17 años, 3 meses
Puntos: 1
Recuperar datos de tabla html

Buenas!!!
Mi problema es el siguiente: Tengo una tabla en html y e puesto el codigo javascript que hace que pueda seleccionar la fila que quiera haciendo click sobre ella, mi pregunta es como hago para recuperar el cod_cliente del registro seleccionado??

Aqui pongo el codigo que tengo:

<html>
<head>
<STYLE TYPE="text/css">{ cursor: pointer }</STYLE>
</head>
<body>
<TABLE border=1 width=100% id="tbuscar">
<TH width=5%>Cod_Cliente</TH><TH width=15%>Nombre</TH><TH width=30%>Apellidos</TH>
<TR style='cursor: pointer'>
<TD>001</TD><TD>Alberto</TD><TD>Garcia</TD>
</TR>
</TABLE>
<script type="text/javascript">
var seleccionado=null;
function onclickHandler()
{
if(seleccionado==this)
{
this.style.backgroundColor="transparent";
seleccionado=null;
}
else
{
if(seleccionado!=null)
seleccionado.style.backgroundColor="transparent";
this.style.backgroundColor="#9999FF";
seleccionado=this;
}
}
var filas=document.getElementById("tbuscar").getElemen tsByTagName("tr");
for(var i=1; i<filas.length; i++)
{
filas[i].onclick=onclickHandler;
}
</script>
</body>
</html>

Muchas gracias