Ver Mensaje Individual
  #7 (permalink)  
Antiguo 28/12/2010, 08:22
Avatar de xalupeao
xalupeao
 
Fecha de Ingreso: mayo-2008
Ubicación: Santiago, Chile
Mensajes: 749
Antigüedad: 16 años
Puntos: 12
Respuesta: Como activar un boton si hay un checkbox seleccionado

Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>Documento sin título</title>
  5. <script type="text/javascript">
  6. function enviar(){
  7.     document.form1.button.disabled = true;
  8.     for (i=0;i<document.form1.elements.length;i++){
  9.         if(document.form1.elements[i].type == "checkbox"){
  10.             if(document.form1.elements[i].checked == 1 ){
  11.                 document.form1.button.disabled = false;
  12.                 i=document.form1.elements.length+10;
  13.             }
  14.         }
  15.     }
  16. }
  17. </head>
  18.  
  19. <form id="form1" name="form1" method="get" action="">
  20.   <input name="campos[]" type="checkbox" id="checkbox" value="1" onchange="enviar();" />
  21.   campo 1<br />
  22.   <input name="campos[]" type="checkbox" id="checkbox2" value="2" onchange="enviar();" />
  23.   campo 2<br />
  24.   <input name="campos[]" type="checkbox" id="checkbox3" value="3" onchange="enviar();" />
  25.   campo 3<br />
  26.   <input name="campos[]" type="checkbox" id="checkbox4" value="4" onchange="enviar();" />
  27.   campo 4
  28.   <br />
  29.   <input type="submit" name="button" disabled="disabled" id="button" value="Enviar" />
  30. </form>
  31. </body>
  32. </html>


Listo :)
__________________
Hosting en Chile en Silverhost - La solución en Hosting en Chile.