Pace
10-27-2002, 06:23 PM
I'm trying to make a little quiz for a website i'm making for my school programming class. I can't get it to count the number right and wrong. here is what i have:
<html>
<head>
<script language="JavaScript">
<!--
function calc_result() {
oAnswer.innerHTML="You got "
+ parseInt(quiz1.q1.value)
+ parseInt(quiz1.q2.value)
+ parseInt(quiz1.q3.value)
+ parseInt(quiz1.q4.value)
+ parseInt(quiz1.q5.value)
+ " out of 5 correct.
";
}
-->
</script>
</head>
<body>
<form name="quiz1">
How many teams move on past the first round in the World Cup?
<input type="radio" name="q1" value="0">32
<input type="radio" name="q1" value="1">16
<input type="radio" name="q1" value="0">8
<input type="radio" name="q1" value="0">4
Which country won the World Cup 2002?
<input type="radio" name="q2" value="0">France
<input type="radio" name="q2" value="0">Germany
<input type="radio" name="q2" value="1">Brazil
<input type="radio" name="q2" value="0">England
Who scored the most goals in the World Cup 2002?
<input type="radio" name="q3" value="0">Landon Danavon
<input type="radio" name="q3" value="0">David Beckham
<input type="radio" name="q3" value="0">Ranaldo
<input type="radio" name="q3" value="0">Ravaldo
How many goals did he score?
<input type="radio" name="q4" value="0">6
<input type="radio" name="q4" value="0">7
<input type="radio" name="q4" value="1">8
<input type="radio" name="q4" value="0">9
How many total goals were scored in the World Cup 2002?
<input type="radio" name="q5" value="0">143
<input type="radio" name="q5" value="0">152
<input type="radio" name="q5" value="0">157
<input type="radio" name="q5" value="0">161
<input type="reset" value="Reset Answers">
<input type="button" value="Submit Answers" onclick="calc_result();">
<span id="oAnswer"></span>
</body>
</html>
here is what happens:
http://www.isaboo.net/pace/quiz.JPG
help me :o
-Pace
<html>
<head>
<script language="JavaScript">
<!--
function calc_result() {
oAnswer.innerHTML="You got "
+ parseInt(quiz1.q1.value)
+ parseInt(quiz1.q2.value)
+ parseInt(quiz1.q3.value)
+ parseInt(quiz1.q4.value)
+ parseInt(quiz1.q5.value)
+ " out of 5 correct.
";
}
-->
</script>
</head>
<body>
<form name="quiz1">
How many teams move on past the first round in the World Cup?
<input type="radio" name="q1" value="0">32
<input type="radio" name="q1" value="1">16
<input type="radio" name="q1" value="0">8
<input type="radio" name="q1" value="0">4
Which country won the World Cup 2002?
<input type="radio" name="q2" value="0">France
<input type="radio" name="q2" value="0">Germany
<input type="radio" name="q2" value="1">Brazil
<input type="radio" name="q2" value="0">England
Who scored the most goals in the World Cup 2002?
<input type="radio" name="q3" value="0">Landon Danavon
<input type="radio" name="q3" value="0">David Beckham
<input type="radio" name="q3" value="0">Ranaldo
<input type="radio" name="q3" value="0">Ravaldo
How many goals did he score?
<input type="radio" name="q4" value="0">6
<input type="radio" name="q4" value="0">7
<input type="radio" name="q4" value="1">8
<input type="radio" name="q4" value="0">9
How many total goals were scored in the World Cup 2002?
<input type="radio" name="q5" value="0">143
<input type="radio" name="q5" value="0">152
<input type="radio" name="q5" value="0">157
<input type="radio" name="q5" value="0">161
<input type="reset" value="Reset Answers">
<input type="button" value="Submit Answers" onclick="calc_result();">
<span id="oAnswer"></span>
</body>
</html>
here is what happens:
http://www.isaboo.net/pace/quiz.JPG
help me :o
-Pace