1. Home
  2. Computing & Technology
  3. JavaScript

Quiz Maker 1 Script

2. Alternate Body Script

With this version of the body script all questions are still displayed one after the other on the same page but instead of hiding and unhiding portions of the page, the entire page is reloaded with just the current question. This version of the script is compatible with more browsers (since it does not require stylesheet processing and the DOM to dynamically update the page) but requires that the page be reloaded for each question.

Query strings are used to pass the current question number and number of correct answers so far between one load of the page and the next. The number of correct answers is concealed so as to reduce the possibility of cheating.

All that you need to do to use this version of the script is to use the code below in place of the body code supplied earlier.

This script is a direct substitution for the script that dynamically updates the same page but it reloads the page for each question instead. You install it the same way as for the other version and if at any time you change your mind as to how you want the script to work just substitute one version of the body script for the other. The only difference apart from reloading the page for each question is that the results are displayed directly on the page instead of being attached to a button.

Now that you have installed whichever version of the body script that you prefer, all that it is missing is an array of questions and answers to display for the quiz. You now need to create your own unique head script containing that array.

The Body Script | Alternate Body Script | The Head Script
Explore JavaScript
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. JavaScript

©2009 About.com, a part of The New York Times Company.

All rights reserved.