Ver Mensaje Individual
  #5 (permalink)  
Antiguo 17/06/2012, 13:05
datpozo
 
Fecha de Ingreso: junio-2012
Mensajes: 3
Antigüedad: 11 años, 10 meses
Puntos: 0
Respuesta: Como guardar datos de texfield dinamicoss

Muchas Gracias por tu ayuda. logre capturar los datos con tu ayuda muchas gracias ta pasaste.

así quedo el código

index.php
Código PHP:
Ver original
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4.  
  5. counter = 1;
  6. function agregarCampo()
  7.     {
  8.         var x = document.getElementById("campos_txt");
  9.         var campo = document.createElement("input");
  10.         campo.setAttribute('type', "text");
  11.         campo.setAttribute('name', "texto"+counter);
  12.         campo.setAttribute('id', "texto"+counter);
  13.         var br = document.createElement("br");
  14.         x.appendChild(document.createTextNode("Dato"));
  15.         x.appendChild(campo);
  16.         x.appendChild(br);
  17.         counter++;
  18.        
  19.     }
  20.  
  21. function borrarElemento()
  22.     {
  23.         var x = document.getElementById("campos_txt");
  24.         x.removeChild(x.lastChild);
  25.         x.removeChild(x.lastChild);
  26.         x.removeChild(x.lastChild);
  27.         counter--;
  28.     }
  29.  
  30.  
  31. </script>
  32.  
  33. </head>
  34. <body>
  35. <h6><a href="#" onClick="agregarCampo()">A&ntilde;adir Campo de Texto</a> | <a href="#" onClick="borrarElemento()">Borrar Campo de Texto</a></h6>
  36. <form name="form1" method="post" action="ingresa.php">
  37. <div id="campos_txt">
  38.  
  39.       <input type="submit" name="button" id="button" value="Enviar">
  40.    
  41. </div> </form>
  42.  
  43. </body>
  44. </html>

ingresa.php
Código PHP:
Ver original
  1. <?php
  2.  
  3.  
  4. foreach($_POST as $var => $val) {
  5.      echo 'input '.$var.'=>'.$val;
  6. }
  7.  
  8. ?>