| You are here: | About>Computing & Technology>JavaScript> Script Makers> Quiz Scripts> Quiz Maker 1 Body Script |
![]() | JavaScript |
Quiz Maker 1 Script1. Quiz Body ScriptJoin the DiscussionMore of this FeatureThe quiz Javascript on this page processes multiple choice quizes having four possible answers to each question one of which is obviously the correct answer and the other three being wrong. You can have as many questions in the quiz as you require subject only to the length of time that it will take to load the resulting web page. With this version of the script all questions are displayed one after the other on the same page (but only one question at a time) or by substituting the alternate body script you can support more browsers by having the page reload to display each question. The quiz questions are displayed one at a time. When an answer is selected and the "Next Question" button pressed an alert advises if an incorrect answer was chosen and the question and possible answers are then replaced by the next one. At the end of the quiz a final button will bring up an alert advising the total number of answers that were correct. Although quizes are just for fun, it spoils the fun somewhat if it is possible to cheat. You will notice when you generate your quiz questions using the quiz generator that there is no single field identifying the correct answer that people will see if they view your page source. Instead there are two apparently random numbers associated with each entry that the script is able to use to work out the right answer when marking each question. The first step in using this script is to obtain the Quiz Javascript and attach it into the body of your page where you want the quiz to appear. If you want to use the version that dynamically updates the page to display the next question then select the code from the text box below (there is a highlight all button beneath it to make this easier) and copy it into a file called quizbody.js. You then link this code into the body of your page where you want the script to appear using the following code:
<script src="quizbody.js"
type="text/javascript"> </script><noscript><table align="center" cellpadding="3" width="350" border="1"><tr> <td align="left"><div><b>This Quiz requires Javascript</b> </div><blockquote>You either have Javascript disabled <br />or the browser you are using does not<br /> support Javascript. Please use a Javascript<br /> enabled browser to access this quiz.<br /> <br /> </blockquote></td></tr></table></noscript> The code contained in this script controls the display of the questions and checking of answers. If you prefer to have the page reload to display each question and thus support earlier browsers that don't allow the page content to be updated dynamically then you need to substitute the alternate body script instead. The Body Script | Alternate Body Script | The Head Script
|
|
All Topics | Email Article | | | ![]() |
| Advertising Info | News & Events | Work at About | SiteMap | Reprints | Help | Our Story | Be a Guide |
| User Agreement | Ethics Policy | Patent Info. | Privacy Policy | ©2008 About, Inc., A part of The New York Times Company. All rights reserved. |


