다른 웹 페이지로 전송되지 않습니다라디오 버튼은 내 코드가 지정된 웹 페이지로 이동하지 않습니다 이유를 볼 수 없습니다
<form name="login" onsubmit="return validateForm()" method="post">
.
.
<input type="radio" name="ans1" id="yes">Yes<br>
<input type="radio" name="ans2" id="no">No<br>
<input type="submit" value="Login" onclick= "where_to_go();">
</form>
스크립트를 where_to_go()
을 위해 :
function where_to_go(){
if (document.login.getElementById('yes').checked) {
// Yes is chosen
document.location.href = "Admin_index.html";
} else if (document.login.getElementById('no').checked) {
// No is chosen
document.location.href ="Log-In_Greet.php";
}
}
어디에서 잘못 알았습니까?
먼저, 사용자가 여러 라디오 버튼을 선택할 수 없도록 라디오 버튼에 동일한 'name' 속성을 사용하려고합니다. 두 번째로 스크립트에서'document.getElementById ('yes'). checked'를 사용하여 시도해보십시오. 무언가에 대해 'id'가있는 경우 더 많은 선택기가 필요하지 않습니다. 왜냐하면 'id '. – PredatorIWD
이것을 스 니펫으로 설정할 수 있으며 validateForm() 함수도 표시 할 수 있습니까? – DCR