
19/02/2014, 19:24
|
| | Fecha de Ingreso: febrero-2008
Mensajes: 409
Antigüedad: 17 años Puntos: 2 | |
Respuesta: Desactivar checkboxes cuando se clickean 5 de ellos Cita:
Iniciado por America|UNK Hola, intenta esta forma:
Código Javascript :
Ver original<input type="checkbox" id="atrib_1" /><br /> <input type="checkbox" id="atrib_2" /><br /> <input type="checkbox" id="atrib_3" /><br /> <input type="checkbox" id="atrib_4" /><br /> <input type="checkbox" id="atrib_5" /><br /> <input type="checkbox" id="atrib_6" /><br /> <input type="checkbox" id="atrib_7" /><br /> <input type="checkbox" id="atrib_8" /><br /> <input type="checkbox" id="atrib_20" /><br /> <script> var checkboxes = function(fn){ var i = 0, box while(i <= 20) (box = document.getElementById("atrib_" + i++), box && fn.apply(box,[])) }; checkboxes(function(){ this.onclick = function(){ var count = 0 checkboxes(function(){ this.checked && count++ }) checkboxes(function(){ !this.checked && count >= 5 ? this.disabled = !0 : this.disabled = !1 }) } }); </script>
no funciona.... |