Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/05/2012, 22:06
i34a23
 
Fecha de Ingreso: agosto-2007
Ubicación: Santiago de Chile
Mensajes: 67
Antigüedad: 16 años, 8 meses
Puntos: 1
Identificar Fila a aplicar funcion

Espero poder explicarme mejor aquí.

tengo la siguiente función Javascript:

Código:
function checked(){
document.getElementById('checkUno').checked=true;
document.getElementById('row').style.backgroundColor="#d2d2d2";
}
function unchecked(){
document.getElementById('checkUno').checked=false;
document.getElementById('row').style.backgroundColor="#ffffff";
}



function CambiaColor(){
if (document.getElementById('checkUno').checked==true){
unchecked();
}
else{
checked();
}

}
Básicamente Selecciona el input checkbox si no lo está y cambia el color de la fila, o deSelecciona el input checkbox si lo esta y vuelve al color original.


el script afecta a la siguiente tabla:

Código PHP:
<body>

<
form id="formularioTest" action="#" method="post">

<
table border="1">
<
tr onClick="CambiaColor()" id="row"><td><input type="checkbox" name="value_0" id="checkUno"></input></td><td><p>Texto aleatorio</p></td></tr>
<
tr onClick="CambiaColor()" id="row"><td><input type="checkbox" name="value_1" id="checkUno"></input></td><td><p>Texto aleatorio</p></td></tr>
<
tr onClick="CambiaColor()" id="row"><td><input type="checkbox" name="value_2" id="checkUno"></input></td><td><p>Texto aleatorio</p></td></tr>
<
tr onClick="CambiaColor()" id="row"><td><input type="checkbox" name="value_3" id="checkUno"></input></td><td><p>Texto aleatorio</p></td></tr>
<
tr onClick="CambiaColor()" id="row"><td><input type="checkbox" name="value_4" id="checkUno"></input></td><td><p>Texto aleatorio</p></td></tr>
</
table>

</
form>



</
body
el problema es que cuando doy click a cualquier input, siempre ejecuta la funcion en el primero, HE AHÍ MI PROBLEMA.

Alguien me puede ayudar y explicarme como hacer que la funcion se ejecute en el checkbox donde se dá el click.

espero puedan ayudarme.

Saludos