Javascript examples for DOM HTML Element:Option
Create option element and Append option to <select>
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from ww w . ja va 2s .co m for(var i=1; i<=5; i++){ var option = document.createElement("option"); option.value = i; option.text = i; document.getElementById('nr').appendChild(option); } } </script> </head> <body> <select id="nr"> </select> </body> </html>