我想在javascript中查看我的mcq问题。如果答案是第4个答案,那么它应警告"纠正"否则它应警告"错误"。这是我尝试过的代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Problem</title>
<link rel="stylesheet" type="text/css" href="mycss.css"/>
<script type="text/javascript">
function validate1(){
one = document.getElementById("1");
two = document.getElementById("2");
three = document.getElementById("3");
if ( (one.checked == true) || (two.checked == true) || (three.checked == true) ){
window.alert ('Wrong answer');
}
else {
window.alert ('correct checked');
}
</script>
</head>
<body>
<h2 align="center">Problems on trains</h2><br></br>
<form name="ques1" action="" method="post" onSubmit="return validate1();">
<h5>1. A train running at the speed of 60 km/hr crosses a pole in 9 seconds. What is the length of the train? </h5>
       120<input type="radio" name="one" value="120" id="1"/>
        180<input type="radio" name="one" value="180" id="2"/>
        324<input type="radio" name="one" value="324" id="3"/>
        150<input type="radio" name="one" value="150" id="4"/>
<input type="submit" value="check"/>
</form>
</body>
</html>