<form name="niu">
<select id="BigCate" name="BigCate" size="1" onchange="Redirect(x)">
<option value="2">全市</option>
<option value="4">主城区</option>
<option value="6">分公司</option>
</select>
</form>JS中的函数Redirect(x)中的'x’,我想让它获取下拉列表选中项的value值,比如选中‘主城区‘,x就获得4,x应该怎么写?

解决方案 »

  1.   


    <form name="niu">
    <select id="BigCate" name="BigCate" size="1" onchange="Redirect(this.selectedIndex,this.options);">
    <option value="2">全市</option>
    <option value="4">主城区</option>
    <option value="6">分公司</option>
    </select><script>
    function Redirect(index,options){
    alert(options[index].value);
    }
    </script>
    </form>
      

  2.   

    请问 这index,options分别代表什么意思?
      

  3.   

        //index表示索引值, options表示传入的所有的option对象
        function Redirect(index,options){
            alert(options[index].value);//返回options中的第index个option的value
        }Redirect(this.selectedIndex,this.options);
    //调用的时候, selectedIndex表示当前选中的索引值, this.options表示此select中的所有option
      

  4.   


    <form name="niu">
    <select id="BigCate" name="BigCate" size="1" onchange="Redirect(this.options[selected].innerText)">
    <option value="2">全市</option>
    <option value="4">主城区</option>
    <option value="6">分公司</option>
    </select>
    </form>
      

  5.   


    $("#BigCate").change(function(){
      var seltext = $("#BigCate").find("option:selected").text();//选择项TEXT
      var selvalue = $("#BigCate").val();//选择项VALUE
    })jquery的代码