The user is supposed to answer the 4 questions and then a pop-up appears telling the user if they have passed or not. I can’t figure out why this is not working correctly. The working website page is here: bit.ly/g4jO3J
Any help would be really appreciated?
<script type = “text/javascript”>
<!–
function validate(myForm) {
var allQuestions = new Array(Quiz.q1,
Quiz.q2,
Quiz.q3,
Quiz.q4);
return checkAnswers(allQuestions);
}
function checkAnswers(allQuestions){
var totalScore = 0; //initialize to 0
for (var i in allQuestions) {
var temp = allQuestions[i];
for (var j = 0; j < temp.length; j++) {
//if the correct one is chosen then add 1 to total score
if (temp[j].value == "correct" && temp[j].checked == true) {
totalScore++;
}
}
}
//if the total percentage is more than 75%
if ((totalScore/allQuestions.length) >= .75) {
alert("Congratulations! Your score of " + totalScore +
" out of " + allQuestions.length + " is very good!");
return true;
}
//otherwise alert and return false
alert(“You must get at least 75% correct to pass!”);
return false;
}
// –>
</script>
</head>
<!–HTML Code Start–>
<body>
<div id=“container”>
<div id=“header”>
<h1>Sideways</h1>
</div>
<div id=“navigation”>
<ul>
<li><a href=“…/index.html”>Home</a></li>
<li>Travelog</li>
<li>Wine Facts</li>
<li><a href=“quiz.html”>Wine Quiz</a></li>
<li>News</li>
<li>Contact</li>
</ul>
</div>
<!–unique html page elements–>
<div id=“content1”>
<div class=“position”>
<div class=“form”>
<h3>Wine Quiz</h3>
<form name="Quiz">
Question 1: Which of these is a letter?<br>
<input type="radio" name="q1" value="correct">A<br>
<input type="radio" name="q1">1<br>
<input type="radio" name="q1">#<br>
<input type="radio" name="q1">None of the Above<br>
<br>
<br>
Question 2: Which of these is a number?<br>
<input type="radio" name="q2">A<br>
<input type="radio" name="q2" value="correct">1<br>
<input type="radio" name="q2">#<br>
<input type="radio" name="q2">None of the Above<br>
<br>
<br>
Question 3: Which of these is a symbol?<br>
<input type="radio" name="q3">A<br>
<input type="radio" name="q3">1<br>
<input type="radio" name="q3" value="correct">#<br>
<input type="radio" name="q3">None of the Above<br>
<br>
<br>
Question 4: Which of these is a comma?<br>
<input type="radio" name="q4">A<br>
<input type="radio" name="q4">1<br>
<input type="radio" name="q4">#<br>
<input type="radio" name="q4" value="correct">None of the Above<br>
<br>
<br>
<input name="button" type="Submit" onClick="return checkAnswers()" />
</form>
</div>
</div>
</div>
</div>
<div id=“footer”>
<ul>
<li>Contact | Terms | Privacy</li>
</ul>
</div>
</body>
</html>