<select id="city">
</select>
for (var i = 0; i < _cityArray.length; i++) {
                        var oOption = document.createElement("Option");
                        oOption.text = _cityArray[i];
                        oOption.value = i;
                        document.getElementById("city").add(oOption);
                    }
_cityArray.length是一个数组。里面有值。执行document.getElementById("city").add(oOption);有错误,请赐教。IE没问题。火狐,opera有问题

解决方案 »

  1.   

    document.getElementById("city").options.add(oOption);
      

  2.   

    还有。while (document.getElementById("city").options.length > 0) {
                            document.getElementById("city").options.remove(0);
                        }
    我添加了一个事件。变换选项的时候。重新绑定city的数据。IE没错。上面先清了下面的数据,再重新绑定。但是火狐那些。绑定一次之后。就不会清理了
      

  3.   

    document.getElementById("city").remove(0);呵呵,火狐在这里让人无所适从了
      

  4.   

    document.getElementById("city").options.add(oOption);
    document.getElementById("city").remove(0);