Ver Mensaje Individual
  #10 (permalink)  
Antiguo 19/10/2009, 08:32
Avatar de gjx2
gjx2
 
Fecha de Ingreso: agosto-2008
Ubicación: R.D
Mensajes: 1.153
Antigüedad: 15 años, 8 meses
Puntos: 139
Respuesta: Ayuda con array por favor

Prueba esto.

Código CODIGO:
Ver original
  1. <?php
  2.  
  3.     if(isset($_POST['btn']) && !empty($_POST['text'])){
  4.    
  5.    
  6.         foreach($_POST['text'] as $row){
  7.        
  8.             echo $row."<br>";
  9.        
  10.         }
  11.     }
  12.  
  13. ?>
  14.  
  15. <script>
  16.  
  17.  
  18. function mk(){
  19.  
  20. var f = document.getElementById("Formulario");
  21. var cantidad = document.getElementById("Cant").value;
  22. for(a=0;a<parseInt(cantidad);a++){
  23.  
  24.    
  25. var input=document.createElement('input');
  26. input.setAttribute('type','text');
  27. input.setAttribute('name','text[]');
  28. input.setAttribute('value','');
  29. f.appendChild(input);
  30.     }
  31.  
  32. }
  33.  
  34. </script>
  35.  
  36.  
  37. <form name="Formulario" id="Formulario" method="post">
  38. <input type="button" onClick="mk()" value="Crear input">
  39. <div>Cantidad Input<input type="text" name="Cant" id="Cant">
  40. <input type="submit" name="btn" value="Enviar">
  41. </div>
  42.  
  43. </form>