Krit Krit - 1 year ago 44
HTML Question

Creating Dynamic Textbox , but code not working

I have just started learning java script.I am trying to make Dynamic text box but the my code is not working . Can someone help me in rectifying my mistake??

<script language="javascript">

function add(){
var text=document.createElement('input');
var add=document.getElementById("Myform");
<form action="new1.php" id="Myform">
<input type="submit" value="Submit" id="submit" onclick="javascript:add();"/> <br/>


The text box disappears before I can do anything with it.

Answer Source

Change the input type as button or other wise it will submit the form.You want the submit button means you have to add one more button for dynamic action.

<input type="button" value="Submit" id="submit" onclick="javascript:add();"/>