Ver Mensaje Individual
  #10 (permalink)  
Antiguo 22/06/2012, 21:00
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 ?

dontexplain gracias por responder


hasta el momento llevo lo siguiente

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

y el formulario es el siguiente

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="hidden" 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="hidden" 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="hidden" name="txtList[]" value="input3" >
  27.     <br/>
  28.  
  29.         <input type="submit" name="enviar" value="Enviar" id="create_account" />
  30. </form>

tengo problemas para implementarlo no me funciona