Tutorial:Scripting: Mutually Exclusive Checkboxes

From GeoGebra Manual
Revision as of 21:00, 13 September 2011 by Birgit Lachner (talk | contribs)
Jump to: navigation, search
Tutorial: Mutually Exclusive Checkboxes

In this tutorial we will show how to create three checkboxes, exactly one of which is always checked. This construction uses Scripting. We will use GGBScript as it is more suitable for simple scripts.

1 Create three checkboxes, a,b and c.

2 Right-click checkbox a, open the Properties Dialog and in Scripting tab (OnUpdate), enter following script to the text area:

SetValue[a,true]
SetValue[b,false]
SetValue[c,false]

Make sure GGBScript is selected in the drop-down menu. Don't forget to confirm the script by clicking OK. Close the Properties Dialog.

3 Repeat the same with checkbox b, just swap a and b in the script:

SetValue[b,true]
SetValue[a,false]
SetValue[c,false]

4 Similarly for checkbox c:

SetValue[c,true]
SetValue[b,false]
SetValue[a,false]

5 Try to click the checkboxes. At each time exactly one should be checked.

See: http://geogebrawiki.wikispaces.com/Radio+Buttons

Similar Ideas for other "buttons"

© 2022 International GeoGebra Institute