【发布时间】:2018-10-19 17:27:32
【问题描述】:
有两个下拉框,当我在第一个下拉列表中选择选项 5 时,应该禁用另一个下拉框。同时,下拉值是从数据库中获取的。
<tr>
<td class="outside scrollable-menu"
style="border-style: none; border-bottom-style: none;">
Education<span
style="color: red;">*</span>
<form:select
path="educationBean.educationId" id="education"
class="form-control modalEdit">
<form:option hidden="hidden" value="">Education</form:option>
<c:forEach items="${educationList}" var="education">
<form:option value="${education.educationId}">${education.educationName}
</form:option>
</c:forEach>
</form:select>
</td>
<td class="outside scrollable-menu"
style="border-style: none; border-bottom-style: none;">
Degree<span
style="color: red;">*</span>
<form:select
path="degreeBean.degreeId" id="degree"
class="form-control modalEdit">
<form:option hidden="hidden" value="">Degree</form:option>
<c:forEach items="${degreeList}" var="degree">
<form:option value="${degree.degreeId}">${degree.degreeName}
</form:option>
</c:forEach>
</form:select>
</td>
</tr>
<script>
function disableDegree() {
if (document.getElementById("education").value === "5") {
document.getElementById("deg").disabled = "true";
} else {
document.getElementById("deg").disabled = "false";
}
}
</script>
【问题讨论】:
-
您想在选择框 1 中的选项 5 时禁用框 2?或者您想在选择框 1 中的任何选项时禁用框 2?
-
我只想在选择选项 5 时禁用。
标签: javascript html