How to create text box dynamically from javascript
html, javascript, jquery
Solution
Try something like this:
function create(param) {
var s= "";
for(var i = 0; i < param; i++) {
s+= '<input type="text" name="Fname">'; //Create one textbox as HTML
}
document.getElementById("screens").innerHTML=s;
}
Problem
I am trying to create textboxes inside `<div id="screens"> </div>`. I have a drop down menu for which I select the number of textboxes to be created. The JavaScript code I've written here is not working: code: ``` function create(param) { document.getElementById("screens").innerHTML=""; for(var i = 0; i < param; i++) { alert(i); document.write('<input type="text" name="Fname">'); } } ``` This is adding textboxes by clearing all contents of the current page, but I want the textboxes to be added to `<div id="screen"> </div>`. How can I do this?