체크 박스의 체크 박스를 수정하려면 어떻게해야합니까? 다음 코드를 참조하십시오. 체크 박스를 클릭하면 '학교'만 채워집니다. 나는 세 단어 모두를 채우고 싶다. 끝에 공간 - - 아니면이없는 당신이 체크 박스 때문에 당신의 HTML에 오타 ("cb3"
라고하지 않기 때문에체크 상자에 체크 상자가있는 경우 텍스트 상자를 업데이트하는 자바 스크립트
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function updatebox()
{
var textbox = document.getElementById("list")
textbox.value = ""
if(document.getElementById('cb2').checked) {
textbox.value = "School"
}
if(document.getElementById('cb3').checked) {
textbox.value = textbox.value + " College "
}
if(document.getElementById('cb4').checked) {
textbox.value = textbox.value + " University"
}
}
</script>
</head>
<body>
<input id="cb2" type="checkbox" name="vehicle" value="School" onclick="updatebox()" /> School <br />
<input id="cb3 "type="checkbox" name="vehicle" value="College" onclick="updatebox()" /> College<br />
<input id="cb4" type="checkbox" name="vehicle" value="University" onclick="updatebox()" /> University<br />
<input id="list" type="text" name="list" />
</body>
</html>
지금 작동, 감사합니다. –