日期:2014-05-16  浏览次数:20302 次

js控制下拉列表框
我现在知道下拉列表框中要选择的值。我现在怎么样用JS来使下拉列表框中的某一项处于选中状态?谢谢!

------解决方案--------------------
selectID.options[3].selected=true
------解决方案--------------------
<select id= "dlt ">
<option value= "1 " selected= "selected "> 1 </option>
<option value= "2 "> 2 </option>
<option value= "3 "> 3 </option>
</select>
<script type= "text/javascript ">
<!--
//方法1
dlt.value=2;
//方法2
dlt.selectedIndex = 2;
//方法3
var opt = dlt.options[0];
opt.selected = true;
//-->
</script>
------解决方案--------------------
下拉框有两个属性value和text,text是能看见的,value是看不见的,要让选中某个需要知道value是多少,语句:
document.getElementById( "下拉框的id ").value = "想要选中的value ";