Ver Mensaje Individual
  #3 (permalink)  
Antiguo 05/05/2011, 05:59
alexg88
 
Fecha de Ingreso: abril-2011
Mensajes: 1.342
Antigüedad: 13 años, 10 meses
Puntos: 344
Respuesta: Checkear varios checkbox con el mismo name

Puedes utilizar la función getElementsByName:

Código HTML:
Ver original
  1. <form id="miformulario" action="#">
  2. <input type="checkbox" name="opcion1" value="1" id="opcion1">
  3. <input type="checkbox" name="opcion1" value="2" id="opcion2">
  4. <input type="checkbox" name="opcion1" value="3" id="opcion3">
  5. <input type="checkbox" name="opcion1" value="4" id="opcion4">
  6. </form>

Código Javascript:
Ver original
  1. function seleccionar(nombre){
  2.   var elementos = document.getElementsByName(nombre);
  3.    
  4.   for (x=0;x<elementos.length;x++)
  5.     elementos[x].checked=true;
  6.  
  7. }