JavaScript

  1. Home
  2. Computing & Technology
  3. JavaScript

Amending Quizes

Changing Question Order or Deleting Questions

By Stephen Chapman, About.com

You can easily change the order of the questions in your quiz. Each quiz question along with the answers etc exists as a single entry within the script that starts with quiz[r++] =. Each of these is on a separate line within your script.

To change the order of the questions within the script you simply change the order in which these entries appear within your script. There is nothing in the entries that relates specifically to the order of the questions, the order of the questions is determined by the value of "r" which is incremented by one for each question in the order that they appear in the file (that's what the ++ means.

Similarly, you can delete questions from the quiz simply by deleting the appropriate entry. Alternatively, if you just want to delete a question temporarily you can add // to the front of the entry. This will co0nvert the entry into a comment and it will be ignored by the script. When you are ready to put the question back in you just remove the //

The only thing that you have to watch for is that you need to leave the lines at the top of the quiz above the first entry alone or you may mess up the creation of the array that contains your quiz details.

Explore JavaScript

About.com Special Features

JavaScript

  1. Home
  2. Computing & Technology
  3. JavaScript
  4. Script Makers
  5. Quiz Scripts
  6. Changing Question Order or Deleting Questions

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

All rights reserved.