var th4 = document.getElementById("ctl00_ContentPlaceHolder1_thirdFieldSelect");
        var th5 = document.getElementById("ctl00_ContentPlaceHolder1_mySelectedItem");
function selectOtherListboxItem()
        {
            for (i=th4.childNodes.length - 1; i>=0;i--)
            {
                if (th4.childNodes[i].nodeType == 1)
                {
                    if (th4.childNodes[i].selected == true)
                     {
                        
                        if(th5.childNodes[i].nodeType == 1)
                        {
                            th5.childNodes[i].selected == true;
                        }
                            
                     }
                    
                }
                
            }
        }  上述代码无法实现,但不报错。

解决方案 »

  1.   

    这样?
    <select id="s1">
    <option value="0">0</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    </select>
    <select id="s2">
    <option value="0">0</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    </select>
    <script>
    var s1 = document.getElementById('s1'), s2 = document.getElementById('s2');
    s1.onchange = function(){
    s2.options[this.selectedIndex].selected=true;
    }
    </script>
      

  2.   

    listbox不是上面的 selection options这个东西,这个叫drop down list
      

  3.   

    问题 我换了个方法解决啦。不过又出现了新的问题我用js 删除了其中一项, 遍历 Listbox 的时候,提示 listbox.childNodes[i].text is undefined,真是奇哉怪也,我用 alert将其 弹出,发现其中有 undefined,于是 if(listbox.childNodes[i].text!="undefined"){...listbox.childNodes[i].text...}
    还提示undefined,真是郁闷
      

  4.   

    问题解决了,if(listbox.childNodes[i].text!=null) 呵呵,汗这么简单的也拿出来问大家
      

  5.   


    看了一下, listbox  是什么东西??   Asp的??