<SELECT onchange="window.location.href=this.options
    [this.selectedIndex].value">
<OPTION VALUE="0">categories</OPTION>
<OPTION VALUE="cat1">1</OPTION>
<OPTION VALUE="cat2">2</OPTION>
<OPTION VALUE="cat3">3</OPTION>
</SELECT>这样的代码可以运行跳转
<SELECT onchange="window.location.href=this.options
    [this.selectedIndex].value">
<OPTION VALUE="0">categories</OPTION>
<OPTION selected ="selected" VALUE="cat1">1</OPTION>
<OPTION VALUE="cat2">2</OPTION>
<OPTION VALUE="cat3">3</OPTION>
</SELECT>但如果有一个默认选项selected的话,就不能跳转到cat1,只能跳转到其它的。有什么解决办法么?

解决方案 »

  1.   

    onchange事件是改变值后才触发的事件,这个事件满足不了你的要求,或者你可以写一个方法实现
    if (changed)
        window.href= ;
    else
        window.href=selected;
      

  2.   


    <SELECT onmousedown="this.selectedIndex=0" onchange="location.href=this.options[this.selectedIndex].value"> 
    <OPTION VALUE="0">categories </OPTION> 
    <OPTION selected ="selected" VALUE="cat1">1 </OPTION> 
    <OPTION VALUE="cat2">2 </OPTION> 
    <OPTION VALUE="cat3">3 </OPTION> 
    </SELECT> 
      

  3.   

    javascript菜鸟。SK_AQI,有详细的实现吗?nmousedown="this.selectedIndex=0"
    加了这个,selected的能选,没selected的就不能选了
      

  4.   

    改成 onmousedown="this.selectedIndex=-1"<SELECT onmousedown="this.selectedIndex=-1" onchange="location.href=this.options[this.selectedIndex].value"> 
    <OPTION VALUE="0">categories </OPTION> 
    <OPTION selected ="selected" VALUE="cat1">1 </OPTION> 
    <OPTION VALUE="cat2">2 </OPTION> 
    <OPTION VALUE="cat3">3 </OPTION> 
    </SELECT> 
      

  5.   

    onchange只有值改变时才会触发,连续的选择同一个的话,第二次不会触发的,就像hookee做的一样,可以强制给他设置个参照,当然这个参照的用途就是用来区分第一次和第二次的选者