Ver Mensaje Individual
  #5 (permalink)  
Antiguo 03/10/2011, 13:40
Avatar de IsaBelM
IsaBelM
Colaborador
 
Fecha de Ingreso: junio-2008
Mensajes: 5.032
Antigüedad: 15 años, 10 meses
Puntos: 1012
Respuesta: evento onclick en tr

se puede hacer mas dinámico. en el caso que usas si no se pulsa en el link, rediccionará a localhost
Cita:
function escucha() {
var trs = document.getElementById('tabla').getElementsByTagN ame('tr');
for (var i = 0; i < trs.length; i++) {
for (var j = 0, tds= trs[i].getElementsByTagName('td'); j< tds.length; j++) {
tds[j].addEventListener( 'click',function(){redireccion(this.innerHTML);},f alse);
}
}
}


function redireccion(valor) {
if (valor != 'eliminar') {
window.location.href='http://localhost/';
} else {
window.location.href='http://loquesea.com';
}
}

window.onload = function() {escucha()};


<table id="tabla" border='1' style="width:50%;margin:0 auto;">
<tr>
<td>Info 1</td>
<td>Info 1</td>
<td>Info 1</td>
<td>eliminar</td>
</tr>
<tr>
<td>Info 2</td>
<td>Info 2</td>
<td>Info 2</td>
<td>eliminar</td>
</tr>
</table>