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?
document.write(). You've usedinnerHTMLin your code, why not to reuse it?