Javascript examples for DOM HTML Element:Option
Add <Option> to <select>
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//www. j a va2s. co m var values = ["First", "Second", "Third"]; var oDDL = document.getElementById("my"); for (var i = 0; i < values.length; i++) { var option = new Option(); option.value = option.text = values[i]; oDDL.appendChild(option); } } </script> </head> <body> <select id="my"></select> </body> </html>