Ver Mensaje Individual
  #12 (permalink)  
Antiguo 23/06/2012, 10:17
Montes28
 
Fecha de Ingreso: septiembre-2010
Mensajes: 1.853
Antigüedad: 13 años, 7 meses
Puntos: 6
Respuesta: en un array se pueden enviar checkbox y input ?

hasta el momento llevo esto pero no se que estoy haciendo mal que no me funciona

Código Javascript:
Ver original
  1. <script type="text/javascript">
  2. $(document).ready(function() {
  3.  
  4.        $('#create_account').click(function(){
  5.  
  6.        var   arrcheckbox = {};
  7.        var   arrhidden = {};
  8.  
  9.  
  10.     $("input[type=checkbox]").each(function(i){
  11.  
  12.      if($(this).attr("checked")){
  13.      arrcheckbox[i]="activo";
  14.     // alert("Activo");
  15.      } else {
  16.      arrcheckbox[i]="inactivo";
  17. //alert("Inactivo");
  18.      }
  19.  
  20.     })
  21.  
  22.     $("input[type=hidden]").each(function(i){
  23. //alert(i),
  24.     arrhidden[i]=$(this).val();
  25.  
  26.    })
  27.  
  28.                
  29.    
  30.                
  31.                
  32.  
  33.        
  34.         var noma= $("#nombre").val();
  35.         var corra= $("#correo").val();
  36.         var telea= $("#telefono").val();
  37.        
  38.        
  39.    
  40.         alert(arrcheckbox);    
  41.    
  42.             //param="nom="+noma+"&corr="+corra+"&boletines="+arrcheckboxt+"&tele="+telea;
  43.           // alert("Nombre:"+" "+noma+"\n"+"Correo:"+" "+corra+"\n"+"Telefono:"+" "+telea+"\n"+"boletines:"+" "+arrcheckbox);
  44.          //  alert(arrayOpt.length);
  45.  
  46.         $.ajax({
  47.             type: "POST",
  48.             url: "account.php",
  49.             data: {"arrcheckbox": checkbox, "arrhidden": arrhidden,"nombre":noma},
  50.              }).done(function(data) {
  51.                
  52.                  
  53.                
  54.    
  55.                   });;
  56.     });
  57. });
  58.  
  59. </script>

Código HTML:
Ver original
  1. <form id="form_account" method="post">
  2.     Nombre:
  3.     <input type="text" name="nombre" id="nombre" />
  4.     <br/>
  5.     <br/>
  6.     Email:
  7.     <input type="text" name="correo" id="correo" />
  8.     <br/>
  9.     <br/>
  10.     Telefono :
  11.     <input type="text" name="telefono" id="telefono" />
  12.     <br/>
  13.     <br/>
  14.     boletines 1 :
  15.     <input class="chk" type="checkbox" name="opcion[]" value="checkbox1" />
  16.     <input type="text" name="txtList[]2" value="input1" >
  17.     <br/>
  18.     <br/>
  19.     boletines 2 :
  20.     <input name="opcion[]" type="checkbox" class="chk" id="opcion[]" value="checkbox2" />
  21.     <input type="text" name="txtList[]3" value="input2" >
  22.     <br/>
  23.     <br/>
  24.     boletines 3 :
  25.     <input name="opcion[]" type="checkbox" class="chk" id="opcion[]" value="checkbox3" />
  26.     <input type="text" name="txtList[]" value="input3" >
  27.     <br/>
  28.     <br/>
  29. boletines 4 :
  30.     <input name="opcion[]" type="checkbox" class="chk" id="opcion[]" value="checkbox4" />
  31.     <input type="text" name="txtList[]" value="input4" >
  32.     <br/>
  33.     <br/>
  34.  
  35.   </p>
  36.     <p>&nbsp;</p>
  37.   <p>&nbsp;</p>
  38.     <p><br/>
  39.         <input type="submit" name="enviar" value="Enviar" id="create_account" />
  40. </form>