Creating An Online Quiz
This is my first attempt at writing my own JavaScript application. I have been reading through the JavaScript Bible (3rd Edition) by Danny Goodman and looking through scripts supplied from and have learned a great deal from both these resources. I have not yet used any of the newsgroups out there as I'm finding that thumbing through the book and taking scripts apart is a great way to learn.
There seems to be a boom in the online quiz, similar to those in magazines it appears that the Internet community are hooked on answering them. Rather than look for the systems which other people are using or directly ripping off their code I thought that making my own quiz would be a simple first project.
The quiz itself is not, at this exact moment in time, finished so the theme, questions and graphics are still a secret (shhh). Hopefully this documenting of the making of my quiz will help you to write your own.
Please feel free to take and use this code. Please also take the time to try and understand what the code is doing, why and how. As with all projects there are many ways of solving a problem and being new to JavaScript I must warn you that my way is not likely to be the easiest.

A File To Store The Questions In
The first decision I made was that I wanted this code to be easy to modify and add to, I did not want the writer to be limited to the amount of questions he could ask and I wanted a central place to add new questions and information.
I created a JavaScript file which basically sets the variables for the questions and is then linked into the page.
The JavaScript name I'm using is quiz1.js and is linked into the page via the following line of code;

<script language=Javascript src="quiz1.js"></script>

The format of the code is pretty simple;

First we set a variable which will later be used to hold the score of the person taking the test;
var runnintotal=0;

The next variable sets how many questions are in the quiz;
var qnum=10;

The following six arrays are defined to contain one element for each question;
var quz = new Array(qnum);
First choice.
var ansA= new Array(qnum);
Second choice.
var ansB = new Array(qnum);
Points given for choosing the first answer.
var valA = new Array(qnum);
Points given for choosing the second answer.
var valB = new Array(qnum);
Choice made by testee.
var ansgiven = new Array(qnum);

The remainder of the JavaScript file is made up of each of the questions and their corresponding answers and points. To keep this simple I'll show just the first question.
quz[1]="1 + 1 = ?";


Valid HTML 4.01!