We can develop a quiz script using client side JavaScript. We will start with a simple quiz where we will ask one question with four options to select. One of them will be the correct answer and other three wrong. We will display correct or wrong message based on the selection of the options by the user. This is a simple quiz where one question is asked and with the understanding of this we will develop more complex quiz with more than one questions and displaying the results.
Here we will use div layers to give the message on the result of the selection of the quiz. We will keep two layers one for displaying correct answer message and other for displaying wrong answer message. These two layers we will keep hidden by default. Once the correct options is clicked then the layer with correct message will be displayed. Same way for other three options we will display the layer having the wrong answer message .
We will use a form with one group of radio buttons having four options. All the radio buttons will have onclick event to trigger the javaScript validate function. One more function setVisibility we will use to manage the visibility of the layers. To control the layers we will call the setVisibility function within the validate function. Here is the javascript functions with in head tags.
<script type="text/javascript">
function validate(form) {
// Checking if at least one period button is selected. Or not.
if (document.form1.q[0].checked ){