Ver Mensaje Individual
  #5 (permalink)  
Antiguo 02/09/2008, 09:06
jcouoh
 
Fecha de Ingreso: septiembre-2003
Ubicación: Merida, yucatan
Mensajes: 282
Antigüedad: 21 años, 4 meses
Puntos: 1
Respuesta: Crear columnas con campos input dynamicamente

Ya lo conseguí,

Solo me gustaría saber si esta esta correcta la sintaxis y si hay declaraciones no indispensables que puedan resumir el codigo.

Este es el codigo:

Código:
<html>
<head>
<title>Problema</title>

</head>
<body>
<form name="myform" action=#>
<input type=text 
name="gasto" 
value="">

<input type=text 
name="factura" 
value="">
</form>

<button onclick="doIt()">do it</button>

<script>
function doIt()
{
var doc = document;
var f = doc.getElementById('myForm');

// show hidden
var el = f.elements.gasto;
el.style.display = "";
var es = f.elements.factura;
es.style.display = "";

// create/insert new
el = doc.createElement("input");
el = f.appendChild(el);
el.name = "newinput";
el.type = "text";
el.value = "";

es = doc.createElement("input");
es = f.appendChild(es);
es.name = "newinput";
es.type = "text";
es.value = "";


}

</script>


</body>
</html>