当前位置: 代码迷 >> Java Web开发 >> 求助!
  详细解决方案

求助!

热度:65   发布时间:2008-01-16 08:40:59.0
求助!
//更新下拉列表
function updateOptions(eSelect,ids,names){
       //清空下拉框

    eSelect.length=0;
    var iLength = ids.length ;
    var iLoop = 0;
    eSelect.options[0]=new Option("","");
    for(iLoop=0;iLoop<iLength;iLoop++){
        var id = ids[iLoop];
        var name = names[iLoop];
        eSelect.options[eSelect.length]=new Option(name,id);
    }
}
eSelect=document.getElementsByName("cityId");
它提示eSelect.length=0; 尚未实现?
有经验的帮解决下
搜索更多相关主题的帖子: ids  iLoop  var  eSelect  

----------------解决方案--------------------------------------------------------
<xhtml>
<head>
<script>
function updateOptions(eSelect) {
    eSelect.length = 0;
    for(i = 0; i < 10; i++) {
        var id = "ID" + i;
        var name = "Name" + i;
        eSelect.options[eSelect.length] = new Option(name,id);
    }
}
</script>
</head>
<body>
<select name="cityId">
</select>
<script>
eSelect=document.getElementsByName("cityId")[0];
updateOptions(eSelect);
</script>
</body>
</xhtml>
----------------解决方案--------------------------------------------------------
谢谢了 我直接在那方法里从得一 次
----------------解决方案--------------------------------------------------------
  相关解决方案