The Journal of Online Mathematics and Its Applications, Volume 7 (2007)
Creating Mathlets with Open Source Tools, Markus Hohenwarter and Judith Preinder

Creating Interactive Exercises using JavaScript

Advanced users who have a little experience with HTML and programming can use the JavaScript interface of GeoGebra applets to add interactive elements like text fields and buttons to their dynamic worksheets. GeoGebra's JavaScript interface provides methods both to observe and modify objects in a construction. You can use these methods for simple things like hiding or showing certain objects when a button is clicked, but also for using GeoGebra as a plug-in for other projects.

In the following example, you will learn how the JavaScript interface can be used to turn a dynamic worksheet into an interactive exercise. To illustrate this process we use our interactive exercise Derivative of a Polynomial.

Creating the Dynamic Figure

Please find information on how to create the dynamic figure for this example in the section Creating "Derivative of a Polynomial".

Note: Although only the sliders a, b, c, and d as well as the polynomial function f are visible on the dynamic worksheet, you need to create some hidden objects for the exercise logic in JavaScript.

Creating Interactive Exercises

In order to extend an existing dynamic worksheet to become an interactive exercise you need to...

  1. Add interactive elements like text fields or buttons to your html page.
  2. Add a short JavaScript program to your html page that implements the functionality for your textfields and/or buttons.
Sorry, the GeoGebra Applet could not be started. Please make sure that Java 1.4.2 (or later) is installed and activated. (click here to install Java now)
Derivative: f ′(x) =

Please find a list of all available methods of GeoGebra's JavaScript interface at GeoGebra Applets and JavaScript. There are several example pages available that help you to get started: Basic JavaScript worksheet, Java to JavaScript communication and Applet to Applet communication.