0
일부 라디오 버튼을 만들고 있는데, 그 중 하나를 클릭하면 몇 개의 필드가 나타납니다. 내 문제는 내가 다음 버튼을 클릭하면 사라질 필요가있는 동안 이전의 필드가 화면에 머물러 있다는 것입니다. 이것은 내가 작성한 코드입니다. 제 실패의 이유는 자바 스크립트 함수에서 else 문을 입력하지 않는다는 것입니다. 누군가 나를 도울 수 있습니까? 저는이 두 언어로 신인입니다. 이전 값을 함수에 보내서 else 문과 비교할 수있는 방법이 있습니까? 다른 해결책도 잘 접수 될 것입니다!javascript와 html을 사용하여 필드를 표시하거나 사라지게하기
<HTML>
<HEAD> <title> Ticket Choice </title></HEAD>
<BODY>
<FORM>
<SCRIPT type="text/javascript">
function IsCheck(but_Check, if_Check){
if (document.getElementById(but_Check).checked) {
document.getElementById(if_Check).style.display = 'block';
}
else document.getElementById(if_Check).style.display = 'none';
}
</SCRIPT>
<input type = "radio" onclick = "javascript:IsCheck("buttonCheck1","ifChecked1");" name = "plane" id = "buttonCheck1"> PLANE <br>
<div id = "ifChecked1" style="display:none">
<label for = "depart">Departure:</label>
<input type = "text" id = "depart" name = "depart_plane" maxlength = "200"><br>
<label for = "dest">Destination:</label>
<input type = "text" id = "dest" name = "destination_plane" maxlength = "200"><br>
</div>
<input type = "radio" onclick = "javascript:IsCheck("buttonCheck2","ifChecked2");" name = "plane" id = "buttonCheck2"> SHIP <br>
<div id = "ifChecked2" style="display:none">
<label for = "depart">Departure:</label>
<input type = "text" id = "depart" name = "depart_ship" maxlength = "200"><br>
<label for = "dest">Destination:</label>
<input type = "text" id = "dest" name = "destination_ship" maxlength = "200"><br>
</div>
<input type = "radio" onclick = "javascript:IsCheck("buttonCheck3","ifChecked3");" name = "plane" id = "buttonCheck3"> O.S.E <br>
<div id = "ifChecked3" style="display:none">
<label for = "depart">Departure:</label>
<input type = "text" id = "depart" name = "depart_ose" maxlength = "200"><br>
<label for = "dest">Destination:</label>
<input type = "text" id = "dest" name = "destination_ose" maxlength = "200"><br>
</div>
</FORM>
</BODY>
</HTML>
완벽한 작품! 감사 – Saraki