A Quiz Using HTML and JavaScript

This is revised. Try the quiz and see what happens. Then view the source.

Try to create a quiz related to your hobby site. The quiz would be multiple choice. Try to come up with at least five questions. The quiz needs to be enclosed in <form> and </form> tags.

Overall, it might look like this (you can use View/Source to see the code):

QuestionsAnswersMarks
Who was the first American to win the World Othello Championship?
A) Brian Rose
B) David Shaman
C) Jonathan Cerf
D) Paul Ralle
A
B
C
D
What is the best description of basic Othello strategy?
A) Stay near the edge of the board
B) Try to minimize the opponent's options
C) Try to capture the most discs early in the game
D) Don't worry about strategy until late in the bame
A
B
C
D

Your overall grade:

To grade the quiz, you need to have the button call a Javascript function, such as
"onClick = (gradequiz(this.form));"

To make sure this function is called correctly, have it write to the textarea. If the name of the textarea is "grade" then you want to have

<script language = "JavaScript">
function gradequiz(form){
form.grade.value = "testing 123";
}
</script>

When this is working, you need to expand the function to read the boxes that the user checks and to compare them with the correct answers. To set up an array of correct answers, you do the following:

rightanswers = new Array();
rightanswers[0] = "C";
rightanswers[1] = "B";
etc.

Page created by Arnold Kling. Last Modified November 26, 2001.