Ver Mensaje Individual
  #7 (permalink)  
Antiguo 05/09/2012, 13:20
Avatar de Dradi7
Dradi7
 
Fecha de Ingreso: junio-2008
Ubicación: Peru - Lima
Mensajes: 1.518
Antigüedad: 16 años, 8 meses
Puntos: 220
Respuesta: Adecuar mi funcion

Revisa este código que acabo de hacer y me dices si funciona a tu perfección

Supongamos que tu tienes estos checkbox

Código HTML:
Ver original
  1. <form name="frm" onsubmit="return false;">
  2. <input type="text" name="p1[]" id="p1" size="3"/><br/><br/>
  3. <input type="text" name="p1[]" id="p2" size="3"/><br/><br/>
  4. <input type="text" name="p1[]" id="p3" size="3"/><br/><br/>
  5. <input type="text" name="p1[]" id="p4" size="3"/><br/><br/>
  6. <input type="text" name="p1[]" id="p5" size="3"/><br/><br/>
  7. <input type="text" name="p1[]" id="p6" size="3"/><br/><br/>
  8. Cambia <input type="checkbox" name="porcentaje" id="porcentaje" value="0"/><br/><br/>
  9. </form>

y este seria el JavaScript

Código Javascript:
Ver original
  1. window.onload = function(){
  2.     var cambia = document.getElementById("porcentaje");
  3.     if(window.attachEvent)
  4.         cambia.attachEvent("onclick",Cambia);
  5.     else
  6.         cambia.addEventListener("click",Cambia);
  7.     Cambia();
  8. };
  9.  
  10. function Cambia(){
  11.     var c = this;
  12.     for (var i = 0; ele = document.getElementsByName("p1[]")[i]; i++){
  13.         ele.disabled = !c.checked;
  14.         console.log(i + " = " + ele.disabled);
  15.     }
  16. }

Acá puedes ver el demo funcionando

http://jsfiddle.net/ldiego/nNSDP/
__________________
La clave de todo triunfador es eliminar todas sus excusas y sus limitaciones