Simple QuizThis script Allows you to generate a simple quiz for the viewer to take. Displays the viewer's results and a percentage grade in an alert box.Script CodeGrab a copy of the file below and place it in the same directory as the Web page on which you will use the script (if you wish to place the script file in a different directory you will need to make the necessary adjustments to the src attribute of the script tag that calls it).The code below should be placed between the <body> and </body> tags where you want the form to appear. ExampleA working sample of the script is shown below.Answer the questions and submit: OptionsYou can change the appearance of the text and form by using the appropriate IDs in your your style sheet and by editing the labels in the HTML as desired.More questions may be added to the quiz by adding them to the HTML file and adding the additional answers in the script file. For example, to add question 6 you could add the following to the HTML code:
<label for="qu_6">6. What is my favorite color? (a) Red (b) Green (c) Blue (d) Orange</label><br /> and add the following to the JavaScript code (in the sgames001.js file): q_answers[5] = "c"; // Answer for Question 6 Note that the array index number is one less than the question number. AccessibilitySetting the form action to link to a backup server-side script that performs the same function should do the trick for those without JavaScript. |