0
2 개의 선택 목록 mySelect 및 mySelect2가 있습니다. 체크 상자를 클릭하면 하나가 선택되면 다른 하나는 동시에 변경됩니다. 당신이 값을 한 번에 변경이 제자리에 변경을 할 수 없도록 어떻게 비활성화 (회색으로) 할 ... mySelect2을jQuery, 값을 새 섹션에 저장하면 입력 사용 안 함
<!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>
:
아래 코드를 확인하십시오?
감사합니다.
어떻게 상자가 JS 버전을 사용을 선택하지 않으면 다시 할 수 있습니까? – avidaicu
위에서 말한 것처럼'disabled' 속성을'false'로 다시 설정하십시오 : document.getElementById ("mySelect2"). disabled = false;' – nnnnnn