Ver Mensaje Individual
  #10 (permalink)  
Antiguo 28/05/2012, 05:48
Avatar de Nemutagk
Nemutagk
Colaborador
 
Fecha de Ingreso: marzo-2004
Ubicación: México
Mensajes: 2.633
Antigüedad: 20 años, 1 mes
Puntos: 406
Respuesta: Multiple checbox-paso de parametro como string

no, yo lo haría de la siguiente manera...

Código HTML:
Ver original
  1. <form name="miForm" method="get" action="www.as.com" onsubmit="return getValues()">
  2.      <input type="checkbox" value="1" />
  3.      <input type="checkbox" value="2" />
  4.      <input type="checkbox" value="3" />
  5.      <input type="checkbox" value="4" />
  6.      <input type="checkbox" value="5" />
  7.      <input type="checkbox" value="6" />
  8.      <input type="hiddent" id="Idcondenv" name="Idcondenv" />
  9.      <input type="submit" value="Enviar" />
  10. </form>

el javascript...
Código Javascript:
Ver original
  1. function getValues() {
  2.      var allvalues = '';
  3.      for(var i=0; i<document.miForm.elements.length; i++) {
  4.           if (document.miForm.elements[i].type == "checkbox") {
  5.                if (document.miForm.elements[i].checked) {
  6.                     allValues = allvalues + ' ' + document.miFirm.elements[i].value;
  7.                }
  8.           }
  9.      }
  10.  
  11.      if(allValues != '') {
  12.           var oculto = document.getElementById('Idcondenv');
  13.           oculto.value = allValues;
  14.           return true;
  15.      }else {
  16.           alert('Debes seleccionar al menos 1 checkbox');
  17.           return false;
  18.      }
  19. }
__________________
Listo?, tendría que tener 60 puntos menos de IQ para considerarme listo!!!
-- Sheldon Cooper
http://twitter.com/nemutagk
PD: No contestaré temas vía mensaje personal =)