Using for loop to generate text boxes - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Text

Description

Using for loop to generate text boxes

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <div id="divSelections"></div> 
      <script type="text/javascript">
function textBox(selections) {//from  w w  w .j  ava2  s . co m
    for (var i=1; i <= selections; i++) {
        document.getElementById('divSelections').innerHTML += '<input type="text" id="MytxBox' + i + '" name=""><br/>';
    }
}
textBox(4) ;

      </script>  
   </body>
</html>

Related Tutorials