Con la ayuda de Google logré hacer esto que consigue que el primer campo (gasto) se duplique tantas veces como se necesite, pero el campo dos (factura) no consigo hacerlo.
Código:
<html>
<head>
<title>Problema</title>
<script language="javascript" src="funciones2.js"
type="text/javascript"></script>
</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 = "";
// create/insert new
el = doc.createElement("input");
el = f.appendChild(el);
el.name = "newinput";
el.type = "text";
el.value = "";
}
</script>
</body>
</html>
y este es el javascript externo:
Código:
function addRowToTable()
{
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var iteration = lastRow;
var row = tbl.insertRow(lastRow);
// left cell
var cellLeft = row.insertCell(0);
var textNode = document.createTextNode(iteration);
cellLeft.appendChild(textNode);
// right cell
var cellRight = row.insertCell(1);
var el = document.createElement('input');
el.type = 'text';
el.name = 'txtRow' + iteration;
el.id = 'txtRow' + iteration;
el.size = 40;
el.onkeypress = keyPressTest;
cellRight.appendChild(el);
// select cell
var cellRightSel = row.insertCell(2);
var sel = document.createElement('select');
sel.name = 'selRow' + iteration;
sel.options[0] = new Option('text zero', 'value0');
sel.options[1] = new Option('text one', 'value1');
cellRightSel.appendChild(sel);
}
si en algo me pueden qyudar que no lo consigo