Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/05/2011, 05:33
xinxan22
 
Fecha de Ingreso: septiembre-2005
Mensajes: 522
Antigüedad: 18 años, 8 meses
Puntos: 0
Checkear varios checkbox con el mismo name

Hola,
como puedo hacer en javascript esto (cuando presiono un botón, chekear los checkbox):

Código Javascript:
Ver original
  1. <script>
  2.  
  3. function seleccionar(la_variable){
  4.    
  5.       forms.lavariable[0].checked=true;
  6.       forms.lavariable[1].checked=true;
  7.       forms.lavariable[2].checked=true;
  8.  
  9. }
  10.  
  11. </script>


Código HTML:
Ver original
  1. SELECCIONAR GRUPO 0:
  2. <input type="button" onclick="seleccionar('tumtum_0');">
  3.  
  4. SELECCIONAR GRUPO 1:
  5. <input type="button" onclick="seleccionar('tumtum_1');">
  6.  
  7.  
  8. <input type="checkbox" name="tumtum_0">
  9. <input type="checkbox" name="tumtum_0">
  10. <input type="checkbox" name="tumtum_0">
  11.  
  12. <input type="checkbox" name="tumtum_1">
  13. <input type="checkbox" name="tumtum_1">
  14. <input type="checkbox" name="tumtum_1">



Me interesa saber si de un "string" puedo hacer referencia al nombre de una variable.



NOTA: No quiero utilizar "id" quiero utilizar "name".
NOTA1: En PHP hay algo parecido a esto utilizando "$$" delante de una variable

Última edición por xinxan22; 05/05/2011 a las 05:42