Tema: doble form
Ver Mensaje Individual
  #4 (permalink)  
Antiguo 12/10/2010, 15:22
georgiy_84
 
Fecha de Ingreso: marzo-2010
Ubicación: Buenos Aires
Mensajes: 25
Antigüedad: 14 años, 1 mes
Puntos: 2
DHTML creación campos de texto dinámicamente

Bueno gente ya solucione problema acá dejo como hice use DHTML creación campos de texto dinámicamente:

Código Javascript:
Ver original
  1. <script type="text/javascript">
  2.                 icremento =0;
  3.                 function crear(obj) {
  4.                   icremento++;
  5.                  
  6.                   field = document.getElementById('field');
  7.                  contenedor = document.createElement('div');
  8.                   contenedor.id = 'div'+icremento;
  9.                   field.appendChild(contenedor);
  10.                  
  11.                  contenedor = document.createElement('div');
  12.                   contenedor.prototype = 'div'+icremento;
  13.                   field.appendChild(contenedor);
  14.                  
  15.                  
  16.                   newtext = document.createTextNode("Nombre de articulo "+icremento+": ");
  17.                   contenedor.appendChild(newtext);
  18.                  
  19.                   boton = document.createElement('input');
  20.                   boton.type = 'text';
  21.                   boton.name = 'name_art'+'[]';
  22.                   contenedor.appendChild(boton);
  23.                  
  24.                   newtext = document.createTextNode(" Cantidad de articulos: ");
  25.                   contenedor.appendChild(newtext);
  26.                  
  27.                   boton = document.createElement('input');
  28.                   boton.type = 'text';
  29.                   boton.name = 'cant_art'+'[]';
  30.                   contenedor.appendChild(boton);
  31.                    
  32.                   boton = document.createElement('input');
  33.                   boton.type = 'button';
  34.                   boton.value = 'Borrar';
  35.                   boton.name = 'div'+icremento;
  36.                   boton.onclick = function () {borrar(this.name)}
  37.                   contenedor.appendChild(boton);
  38.                 }
  39.                 function borrar(obj) {
  40.                   field = document.getElementById('field');
  41.                   field.removeChild(document.getElementById(obj));
  42.                 }
  43.               </script>

Código HTML:
<fieldset id="field">
                <input type="button" value="Crear articulo" onclick="crear(this)">
                </fieldset>