Hola
yazo
Prueba este código:
Código PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Formularios Dinamicos</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
var cont = 0;
function addLine() {
tab = document.getElementById('tabla');
fila = tab.appendChild(document.createElement('tr'));
celda = fila.appendChild(document.createElement('td'));
//
campo = celda.appendChild(document.createElement('input'));
campo.name='orden'
campo.id='orden'+cont;
//
campo = celda.appendChild(document.createElement('input'));
campo.name='concepto'
campo.id='concepto'+cont;
//
campo = celda.appendChild(document.createElement('input'));
campo.name='precio'
campo.id='precio'+cont;
//
campo = document.createElement('input');
campo.type='button';
campo.name='orden'
campo.id='orden'+cont;
campo.onclick=function() {
tab = document.getElementById('tabla');
padre = this.parentNode.parentNode;
tab.removeChild(padre);
}
celda.appendChild(campo);
cont++;
}
// Se borra la linea solicitada
function delLine(div){
var content = document.getElementById('myDiv');
var remove = document.getElementById(div);
content.removeChild(remove);
}
</script>
</head>
<body>
<form method="POST" action="">
<a href="#" onclick="addLine();return false">Añadir Linea +</a><br>
<table>
<tbody id="tabla">
</tbody>
</table>
<br><input type="submit">
</form>
</body>
</html>
Saludos,