要做這樣一種功能,當我點擊左邊的下拉框的時候,右邊下拉框啟用進行選擇。如下圖:
當左邊重新點擊“請選擇”的時候,右邊選擇狀態清空並禁用:
這個很好做,用到只需要獲取所選擇Index就行(默認從0開始) 下面是js代碼:
function changeMorTime(obj)
{
//當左邊select控件所選擇為請選擇時
if (obj.selectedIndex == 0)
{
//獲取 右邊用葯計量控件
var cselc = document.getElementById("MorTime");
cselc.options.selectedIndex = 0; //回到初始狀態
$("#MorTime").attr("disabled", "disabled");//禁用
}
else
{
$("#MorTime").removeAttr("disabled");
}
}
html代碼如下:
<td>
<select class=" check-input" onload="IninSageALLTime()" onchange="changeMorTime(this)" id="dosageMorTime" name="dosageMorTime" required="required">
</select>
</td>
<td >
<select class=" check-input" " name="dosagesize" id="MorTime" required="required">
</select> 片
</td>
以上寫的有點混亂既有js也有jquery,有需要的可以自己更改一下。