![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
29/01/2009, 16:11
|
Usuario no validado | | Fecha de Ingreso: marzo-2007
Mensajes: 238
Antigüedad: 17 años, 11 meses Puntos: 5 | |
Respuesta: agregar campos dinamicamente con js Hola, a esto me referia:
<form id="myForm" method="post">
<table width="650" border="1" cellspacing="4" cellpadding="4">
<tr>
<td>NOMBRE</td>
<td>DIRECCION</td>
<td>FECHA NAC</td>
</tr> <tr>
<td><input type="text" name="poll[question]"> </td>
<td><input type="text" name="poll[option1]"> </td>
<td><input type="text" name="poll[option2]"> </td>
</tr>
</table>
<input type="submit"> <a href="javascript:addOption();">Add option</a>
</form>
<script>
var optionNumber = 3; //The first option to be added is number 3
function addOption() {
var theForm = document.getElementById("myForm");
var newOption = document.createElement("input");
newOption.name = "poll[option"+optionNumber+"]"; // poll[optionX]
newOption.type = "text";
theForm.appendChild(newOption);
optionNumber++;
}
</script>
pero en el script como le indico duplique todo, se puede? |