<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应该怎么写?
<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应该怎么写?
<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>
function Redirect(index,options){
alert(options[index].value);//返回options中的第index个option的value
}Redirect(this.selectedIndex,this.options);
//调用的时候, selectedIndex表示当前选中的索引值, this.options表示此select中的所有option
<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>
$("#BigCate").change(function(){
var seltext = $("#BigCate").find("option:selected").text();//选择项TEXT
var selvalue = $("#BigCate").val();//选择项VALUE
})jquery的代码