注册 登录
编程论坛 J2EE论坛

求助!

风飞凡 发布于 2008-01-16 08:40, 937 次点击
//更新下拉列表
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; 尚未实现?
有经验的帮解决下
2 回复
#2
liugy522008-01-16 11:03
<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>
#3
风飞凡2008-01-18 19:32
谢谢了 我直接在那方法里从得一
1