Ver Mensaje Individual
  #2 (permalink)  
Antiguo 06/10/2010, 15:43
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 9 meses
Puntos: 1567
Respuesta: Deshabilitar checkbox a travez de un select

soldierjesus:
Este ejemplo es muy genérico, porque hace que cualquier opción del select desmarque todos los checkbox (en caso de que tuvieses más de uno)

Habría que ajustarla para algo más preciso

Código HTML:
Ver original
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  3.    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es">
  5. <title>CheckBox</title>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <meta name="copyright" content="&copy; 2006, Guillermo Gianello" xml:lang="es" lang="es" />
  8. <meta name="author" content="http://emprear.com"  xml:lang="es" lang="es" />
  9.  
  10. <script type="text/javascript">
  11. //<![CDATA[
  12. function des(){
  13. var cbv = document.form1.dia.value;
  14. var i = "";
  15.   for (i=0;i<document.form1.elements.length;i++){
  16.    if(cbv != ""){
  17.         document.form1.elements[i].checked=0
  18. }
  19. }
  20.  
  21. }
  22. //]]>
  23. </head>
  24. <div>
  25. <p>Cambiar estado checkbox a través de select onchange</p>
  26. <form method="post" action="#" name="form1">
  27. <select name="desmarcar" onchange="des();">
  28. <option value="">Su opción</option>
  29. <option value="a">A</option>
  30. <option value="b">B</option>
  31. <br /><br />
  32. lunes<input type="checkbox" name="dia" checked="checked" value="lunes"/>
  33. martes<input type="checkbox" name="dia" value="martes" checked="checked" />
  34. <input type="submit" value="enviar" />
  35. </form>
  36. </div>
  37. <!-- ©2000 Emprear.com -->
  38. </body>
  39. </html>


demo
http://foros.emprear.com/html/sniper/select-cb.html


Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.