List of Topics

SfC Home > Training > eLearning >

 

Using JavaScript Alert Buttons

by Ron Kurtus (12 July 1998)

Multiple-choice questions are often used in Computer-Based Training (CBT) to test or verify a learner's knowledge, as well as to keep the person's interest in the lesson.

The advantage of such questions in CBT is that the student can immediately get feedback as to whether the answer was correct and/or what the correct answer is.

A simple way to do this in Web-Based Training (WBT) or Intranet-Based Training (IBT) is to use the alert button feature of JavaScript. This lesson will show examples of using the alert button and provide the JavaScript code.



Check if JavaScript is Available

While most browsers these days can read JavaScript, there still are people with old browsers that can't use this feature. Also, some people may have the function turned off in their browser.

You can use an alert button to let your students check if your multiple choice will work properly with their browsers.

Click this button to see if you have JavaScript available.
If there is no response, you are just out of luck.

Example of Multiple Choice Quiz

The following multi-choice question is an example of using alert buttons to let the learner know whether the answer was right or wrong, as well as to give some information about the answer.

Unfortunately, this simple method does not let the instructor know how well the student is doing. Rather, it is primarily intended to help the student's learning experience.

1. Why would you use JavaScript for WBT?

JavaScript Code

The following code was used for this example.

<HEAD>

The code placed under the HTML <HEAD> consists of the comments for the various alert windows that pop up after the given button was clicked.

<script language="JavaScript">
<!--
function AlertBox1(){
alert("Yes, you have JavaScript available.")
}
function AlertBox2(){
alert("Sorry. Multimedia doesn't work well with JavaScript.")
}
function AlertBox3(){
alert("Not right. You need to be on the Web or your Intranet to use JavaScript. Try another answer.")
}
function AlertBox4(){
alert("That is correct. You are a genius.")
}
//-->
</script>

<BODY>

The code for the multiple choice is placed under the <BODY> section, in the area you want the question.

<p><strong>1. Why would you use JavaScript for WBT?</strong></p>
<form>
<div align="left"><p><input type="button" name="B1"
value="a. So you can do multimedia effects." onclick="AlertBox2()"></p>
</div><div align="left"><p><input type="button" name="B2"
value="b. To avoid using the Internet." onclick="AlertBox3()"> </p>
</div><div align="left"><p><input type="button" name="B3"
value="c. Most browsers can read JavaScript." onclick="AlertBox4()"></p>
</div>
</form>

Summary

Using alert buttons with JavaScript is a useful tool in providing web-based training, although it has its limitations.


Teach others


Resources and references

Ron Kurtus' Credentials

Websites

eLearning Resources

Books

Top-rated books on eLearning


Questions and comments

Do you have any questions, comments, or opinions on this subject? If so, send an email with your feedback. I will try to get back to you as soon as possible.


Share

Click on a button to bookmark or share this page through Twitter, Facebook, email, or other services:

 

Students and researchers

The Web address of this page is:
www.school-for-champions.com/elearning/
using_js_alert_buttons.htm

Please include it as a link on your website or as a reference in your report, document, or thesis.

Copyright © Restrictions


Where are you now?

School for Champions

eLearning topics

Using JavaScript Alert Buttons




eLearning topics

Improving Business

Developing eLearning Material

Developing WBT

Also see



Let's make the world a better place

Be the best that you can be.

Use your knowledge and skills to help others succeed.

Don't be wasteful; protect our environment.

You CAN influence the world.





Live Your Life as a Champion:

Take care of your health

Seek knowledge and gain skills

Do excellent work

Be valuable to others

Have utmost character

Be a Champion!



The School for Champions helps you become the type of person who can be called a Champion.