Twenty-four Simple javascripts for exercises on Web pages. 

Here are  twenty-four examples of  using simple javascripts to create questions. All of these can be simply copied and pasted and then altered through simple substitutions. They do not require the use of functions.    All the answers (save for proper names) that need to be typed in should be in lower case. No extra spaces should be present before or after a word, and only one space between words. 

If you click on the link in the right-hand column, you can see the script that generates the example. 

If you go here, you will see these scripts in detail, plus some notes and links to examples. 
 

 
One A button for a correct answer. When pressed, an alert says "Yesss!  See Script
Two A button for an incorrect answer When pressed, an alert says "No, try again!".  See Script
Three  Here is an example of using the buttons above for a multiple choice review question. 

Who ran away with Paris Alexander and thus caused the Trojan war?

See Script
Four Here you click on the button, a prompt asks you for the answer to a question. 
Then it shows your the correct answer and asks you if your answer was correct. 

The main Greek god of the sea was: 

See Script
Five  Here you click on the button, then a prompt asks you for the answer to a question. 
Then, if your are right, an alert tells you so. If not, it indicates the answer is incorrect
and shows the correct answer. 

The main Greek god of the sea was (Answer is Poseidon): 

See Script
Six  Here you click on the button, then a prompt asks you for the answer to a question. 
Then, if your are right, an alert tells you so. If not, it indicates the answer is incorrect
and shows the correct answer. This button allows for two correct answers. 

Your question. (Possible answers are: your answer or your second answer

See Script
Seven Here you type an answer into a field, and when you click on button, an alert tells you whether the answer is correct or not. 

(Answer is your answer)

See Script
Eight  This is another version of the same button in Seven, but it has two possible correct answers

(Possible answers are your answer or your second answer)

See Script
Nine  This is another version of the same button in Seven, but it has three possible correct answers

(Possible answers are: your answer or your second answer or your third answer)

See Script
Ten   This is a version of the 3-answer question above in Nine, save that, instead of clicking on a button, you simply hit the tab key once you have typed the answer in.

(Possible answers are: your answer or your second answer or your third answer)

See Script
Eleven Here you type answer in the field, and, when you click on the button the small box gets a 1 or 0 depending on whether the answer is correct. 

(Answer is your answer)

See Script
Twelve This button is like Eleven, but allows for two possible correct answers: 

The possible answers are: your answer or your second answer)

See Script
Thirteen  This is a version of the 2-answer Twelve, save that, instead of clicking on a button, you simply hit the tab key once you have typed the answer in.

The possible answers are: your answer or your second answer)

See Script
Fourteen Here you type answer in the field, and, when you click on the button the small box gets a 1 or 0 depending on whether the answer is correct, plus there is an alert that tells you if you are right or wrong and what the correct answer is: 

Answer is your answer)

See Script
Fifteeen  This works the same as the question immediately above except it allows for two answers.

Possible answers are: your answer or your second answer

See Script
Sixteen  This works the same as the Fourteen  except it uses the tab key.

Possible answers are: your answer or your second answer

See Script
Seventeen  Here you select radio button, then click button. An alert 
will indicate whether answer is correct and give feedback. 

Which Greek god was the patron of Samos? (Hera)

AthenePosidonHeraZeus 

See Script
Eighteen Here you select radio button, then click button. An alert will indicate whether answer is correct
and give feedback. A 1 or 0 will appear in the field depending on whether the answer is correct.

Which Greek god was the patron of Samos? (Hera)

AthenePosidonHeraZeus 

See Script
Nineteen  Here you select radio button, then click button. Then simply a 1 or 0 will appear in the
field depending on whether the answer is correct.

Which Greek god was the patron of Samos? (Hera)

AthenePosidonHeraZeus 

See Script
Twenty Here you fill in answers in two fields, and answers have to be right in both fields 
the prompt to give the Yesssss! response. You can make the prompt give the correct answer in response to a wrong answer.

Answer for first field is answer one. Answer for second field is answer two.

See Script
Twenty-one Again, type answers in two fields, and when you click the button you merely get a 1 or 0 in the small field, depending on whether the answer is correct. 
 

Answer for first field is answer one. Answer for second field is answer two

See Script
Twenty-two Again, type answers in two fields. This time, when you click the button a message in the long field will tell you whether you are correct, your score for that exercise and feedback concerning the correct answer. 
 

Answer for first field is answer one. Answer for second field is answer two

See Script
Twenty-Three Here you type one answer in the field, then check a radio button to give a further answer. When you click the "Check Answer" button a message in the long field indicates whether you are correct, your score for that exercise and feedback concerning the correct answer. 

Answer for first field is of the men. The radio button to pick is gen.

Translate virorum according to case and then indicate the case. 

Your Translation: Nom.Gen.Dat.Acc.Abl. 

See Script
   
Twenty-Four This is a simple reset button. It will clear all the fields on the form. 

See Script
 Go To Page Containing All Scripts.   

  Hit Counter hits since 23 August 1999


Copyright 1999 Jean Alvares

Return to Jean Alvares' Javascript Guide and Links