html - Populate select list using javascript -


i trying populate html select list using javascript. believe doing correctly, not able populate list. list still empty. missing here?

html:

<%@ page language="c#" inherits="system.web.mvc.viewpage<dynamic>" %> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">  <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <script type="text/javascript" src="../../scripts/app/base.js"></script>     <title>index</title> </head>  <body>     <div>     select <select id = "mylist"></select>     </div> </body> </html> 

js:

window.onload = function(){     var select = document.getelementbyid("mylist");     var options = ["1", "2", "3", "4", "5"];     (var = 0; < options.length; i++) {         var opt = options[i];         var el = document.createelement("option");         el.textcontent = opt;         el.value = opt;         select.appendchild(el);     } } 

do mean window.onload ?

fiddle: http://jsfiddle.net/5jr8n/


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -