Consult the Crystal Ball


Enter your question below.






Return to the
Javascript Playground

Download
This Page

About This Page

The question, answer, and buttons are part of a FORM. The question is obtained from the FORM text box using a JavaScript function called by the onClick event.

There are 52 possible answers stored in an array. When a question is entered, a check is made to see if the question text box has something in it (if not, an alert is put up). A "random" number between 0 and 51 is calculated from the time the question was posed. This number is used to select the answer. The answer is written to the other text box.

See another implementation of this script.

©Lewis A. Shadoff, 1998