Ver Mensaje Individual
  #2 (permalink)  
Antiguo 21/05/2010, 14:23
Avatar de Adler
Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 17 años, 4 meses
Puntos: 126
Respuesta: Cambiar color background a DIV con checkBox

Hola

Sería algo como esto

Código Javascript:
Ver original
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. window.onload = function() {
  5. cant_tr = document.body.getElementsByTagName('tr');
  6. cant_inpt = document.body.getElementsByTagName('input');
  7.  
  8.     for (i=0; i < cant_tr.length; i++) {
  9.  
  10.         for (j=2; j < cant_inpt.length; j+=3) {
  11.  
  12.             cant_inpt[j].onclick = function() {
  13.                 document.getElementById('td_'+this.id).style.backgroundColor = 'red';
  14.  
  15.             }
  16.         }
  17.     }
  18. }
  19. </script>
  20. </head>
  21. <body>
  22. <table border="1">
  23. <tr id="td_1">
  24. <td><input type="text" value="" /></td><td><input type="text" value="" /></td><td>&nbsp<input type="checkbox" id="1" /></td>
  25. </tr>
  26. <tr id="td_2">
  27. <td><input type="text" value="" /></td><td><input type="text" value="" /></td><td>&nbsp<input type="checkbox" id="2" /></td>
  28. </tr>
  29. <tr id="td_3">
  30. <td><input type="text" value="" /></td><td><input type="text" value="" /></td><td>&nbsp<input type="checkbox" id="3" /></td>
  31. </tr>
  32. </table>
  33. </body>
  34. </html>

Suerte
__________________
Los formularios se envían/validan con un botón Submit
<input type="submit" value="Enviar" style="background-color:#0B5795; font:bold 10px verdana; color:#FFF;" />