<form action="" method="post" id="form">
<div class="textfields-container">
<div class="textfield-container"></div>
</div>
<input type="button" name="addTextfield" id="addTextfield" value="Add Textfield"/>
<input type="submit" value="Submit"/>
</form>
<script>
document.getElementById("addTextfield").addEventListener("click", function(){
var textfield = document.createElement("input");
textfield.type = "text";
textfield.name = "textfield[]";
var textfieldContainer = document.querySelector(".textfields-container");
textfieldContainer.appendChild(textfield);
});
</script>
No hay comentarios:
Publicar un comentario