現在有一id為userType的下拉框,怎么獲取選中的值:
1 用戶類型: 2 <select name="type" id="userType"> 3 <option value="0">請選擇</option> 4 <option value="1">普通類型</option> 5 <option value="2">VIP類型</option> 6</select>
js操作:
1 var myType = document.getElementById("userType");//獲取select對象 2 var index = myType.selectedIndex; //獲取選項中的索引,selectIndex表示的是當前所選中的index
3 myType.options[index].value;//獲取選項中options的value值
4 myType.options[index].text;//獲取選項中options的value值