スクリプトは、正解または不正解のJavascriptアラートを表示することになっていますが、アラートはポップアップしません。何が問題なのですか?簡単に修正できると思いますが、見つけられないようです。私はすでにページ全体を検証し(これは単なるスニペットです)、検証に合格しました。
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
function scoreQuestion1(answer){
if (answer == "a")
window.alert("Correct Answer");
if (answer == "b")
window.alert("Incorrect Answer");
if (answer == "c")
window.alert("Incorrect Answer");
if (answer == "d")
window.alert("Incorrect Answer");
}
function scoreQuestion2(answer){
if (answer == "a")
window.alert("InCorrect Answer");
if (answer == "b")
window.alert("Incorrect Answer");
if (answer == "c")
window.alert("Correct Answer");
if (answer == "d")
window.alert("Incorrect Answer");
}
function scoreQuestion3(answer){
if (answer == "a")
window.alert("Incorrect Answer");
if (answer == "b")
window.alert("Correct Answer");
if (answer == "c")
window.alert("Incorrect Answer");
if (answer == "d")
window.alert("Incorrect Answer");
function scoreQuestion4(answer){
if (answer == "a")
window.alert("Incorrect Answer");
if (answer == "b")
window.alert("Incorrect Answer");
if (answer == "c")
window.alert("Correct Answer");
if (answer == "d")
window.alert("Incorrect Answer");
}
function scoreQuestion5(answer){
if (answer == "a")
window.alert("Incorrect Answer");
if (answer == "b")
window.alert("Incorrect Answer");
if (answer == "c")
window.alert("Incorrect Answer");
if (answer == "d")
window.alert("Correct Answer");
}
</script>
</head>
<body>
<form action="" name="quiz">
<p><strong>1. How many natural elements are there?</strong></p><p>
<input type="radio" name="question1" value="a" onclick="scoreQuestion1('a')" />92<br /> <!-- correct answer-->
<input type="radio" name="question1" value="b" onclick="scoreQuestion1('b')" />113<br />
<input type="radio" name="question1" value="c" onclick="scoreQuestion1('c')" />103<br />
<input type="radio" name="question1" value="d" onclick="scoreQuestion1('d')" />88<br /></p>
<p><strong>2. If one kg of air is compressed from 1m3 to 0.5 m3, which of the following statements is true?</strong></p><p>
<input type="radio" name="question2" value="a" onclick="scoreQuestion2('a')" />The density is halved.<br />
<input type="radio" name="question2" value="b" onclick="scoreQuestion2('b')" />The mass is halved.<br />
<input type="radio" name="question2" value="c" onclick="scoreQuestion2('c')" />The density is doubled.<br /> <!--correct answer-->
<input type="radio" name="question2" value="d" onclick="scoreQuestion2('d')" />The mass is doubled.<br /></p>
<p><strong>3. What is the acceleration due to gravity?</strong></p><p>
<input type="radio" name="question3" value="a" onclick="scoreQuestion3('a')" />980 m/s2<br />
<input type="radio" name="question3" value="b" onclick="scoreQuestion3('b')" />9.8 m/s2<br /> <!--correct answer-->
<input type="radio" name="question3" value="c" onclick="scoreQuestion3('c')" />98 m/s2<br />
<input type="radio" name="question3" value="d" onclick="scoreQuestion3('d')" />0.98 m/s2<br /></p>
<p><strong>4. What is the SI unit of density?</strong></p><p>
<input type="radio" name="question4" value="a" onclick="scoreQuestion4('a')" />cm3/g<br />
<input type="radio" name="question4" value="b" onclick="scoreQuestion4('b')" />m3/kg<br />
<input type="radio" name="question4" value="c" onclick="scoreQuestion4('c')" />kg/m3<br /> <!--correct answer-->
<input type="radio" name="question4" value="d" onclick="scoreQuestion4('d')" />g/cm3<br /></p>
<p><strong>5. Which of these has the highest density?</strong></p><p>
<input type="radio" name="question5" value="a" onclick="scoreQuestion5('a')" />Lead<br />
<input type="radio" name="question5" value="b" onclick="scoreQuestion5('b')" />Water<br />
<input type="radio" name="question5" value="c" onclick="scoreQuestion5('c')" />Mercury<br />
<input type="radio" name="question5" value="d" onclick="scoreQuestion5('d')" />Tungsten<br /></p> <!--correct answer-->
</form>