http://www.cnode.cn/test/default.html
谁能帮我看一下,为什么在IE6下最后一个SELECT不正常
最后一个列表无法选择。

解决方案 »

  1.   

    不是广告!~~ 我晕。。
    你们那边使用IE6都正常?难不成只有我们公司的IE6不正常?
      

  2.   

    最简单的解决方案就是天选项不用重新改变options
                var setElDate = function (noChangeOption) {
                    var yVal = $(sltYear).val(),
                    mVal = $(sltMonth).val(),
                    dVal = $(sltDay).val();
                    el.val(yVal + "-" + mVal + "-" + dVal);
                    if (noChangeOption) return;
                    jMiniCalendar.innerOption(sltDayId, 1, jMiniCalendar.getMaxDay(yVal, mVal), dVal);
                };            $(sltDay).change(function () {
                    return setElDate(true);
                });
      

  3.   

    解决问题的第一步就是分解问题:
    <select id="select_temp" onchange="changeOptions()"></select>
    <script>
    function changeOptions() {
    var select_temp = document.getElementById("select_temp");
    var value = select_temp.selectedIndex;
    while (select_temp.firstChild) {
    select_temp.removeChild(select_temp.firstChild);
    }
    for (var i = 0; i < 10; i++) {
    var option = new Option(i, i);
    if (i == value) option.selected = true;
    select_temp.options.add(option);
    }
    }
    changeOptions();
    </script>
    这样就重新了楼主的问题。
    关键的地方:在IE6下,onchange事件中设置添加的option.selected无效。可通过设置selectedIndex解决此问题。
    <select id="select_temp" onchange="changeOptions()"></select>
    <script>
    function changeOptions() {
    var select_temp = document.getElementById("select_temp");
    var value = select_temp.selectedIndex;
    while (select_temp.firstChild) {
    select_temp.removeChild(select_temp.firstChild);
    }
    for (var i = 0; i < 10; i++) {
    var option = new Option(i, i);
    select_temp.options.add(option);
    }
    select_temp.selectedIndex = value;
    }
    changeOptions();
    </script>正如我楼上所说,最简单和合理的方法就是选择天数时不用重新生成options