码迷,mamicode.com
首页 > Web开发 > 详细

js动态添加菜单

时间:2015-02-11 23:14:01      阅读:315      评论:0      收藏:0      [点我收藏+]

标签:

<script type="text/javascript">window.onload = initForm; 
  
function initForm() {
     document.getElementById("months").selectedIndex = 0;
     document.getElementById("months").onchange = populateDays;
}
  
function populateDays() {
     var monthDays = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
     var monthStr = this.options[this.selectedIndex].value;
  
     if (monthStr != "") {
        var theMonth = parseInt(monthStr);
        document.getElementById("days").options.length = 0;
        for(var i=0; i<monthDays[theMonth];i++) {
           document.getElementById("days").options[i] = new Option(i+1);
        }
     }
}
</script>

 

js动态添加菜单

标签:

原文地址:http://www.cnblogs.com/liangjiehai/p/4287081.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!