Adding HTML element inside of a JavaScript loop - Javascript DOM

Javascript examples for DOM:Document write

Description

Adding HTML element inside of a JavaScript loop

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <h2 style="text-align:center"> On a scale from 1-10, how likely are you to recommend this site to a friend or colleague? </h2> 
      <form id="NPSform" ; style="text-align:center"> 
         <script>
                for (var i = 1; i <=10; i++) {
                    document.write('<input type="radio" name="scores" id="i" value="i">'+ i);
                }/*from   w  w w  .j  a v a 2s . com*/
            
         </script> 
         <input type="submit" name="mysubmit" value="Submit"> 
      </form>  
   </body>
</html>

Related Tutorials