我有 2 个选择列表 mySelect 和 mySelect2。当您单击复选框选择一个时,另一个同时更改。
请检查以下代码:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function displayResult() {
if(document.form1.billingtoo.checked == true) {
var x = document.getElementById("mySelect").selectedIndex;
// Set selected index for mySelect2
document.getElementById("mySelect2").selectedIndex = x;
}
}
</script>
</head>
<body>
<form name="form1">
Select your favorite fruit:
<select id="mySelect">
<option>Apple</option>
<option>Orange</option>
<option>Pineapple</option>
<option>Banana</option>
</select>
<br>
<input type="checkbox" name="billingtoo" onclick="displayResult()">
<br>
Select your favorite fruit 2:
<select id="mySelect2">
<option>Apple</option>
<option>Orange</option>
<option>Pineapple</option>
<option>Banana</option>
</select>
</form>
</body>
</html>
...如何禁用(灰色)mySelect2,以便在值到位后无法进行任何更改?
谢谢。