使用javascript进行MCQ验证
我想用javascript检查我的mcq问题。如果答案是第四个,它应该警告正确,否则它应该警告错误。以下是我尝试过的代码:使用javascript进行MCQ验证,javascript,html,Javascript,Html,我想用javascript检查我的mcq问题。如果答案是第四个,它应该警告正确,否则它应该警告错误。以下是我尝试过的代码: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Problem</title> <link rel="stylesheet" type="text/css"
<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>
PMI,但MCQ将是…?多项选择题您提交的内容不包含任何问题。如果选择了4,为什么不直接做呢。选中{//correct}否则{//error}我也使用了该选项。但它仍然没有显示正确的警报框