NavigationLibrariesdoctype [?][strict] [loose] [none] |
Check Box Groups |
||||
Including The ScriptInclude a reference to the js file in the HEAD of your HTML page. <script type="text/javascript" src="checkboxgroup.js"></script> Creating The Objectvar myOptions = new CheckBoxGroup(); Adding Checkboxes To The GroupUse the addToGroup method of the object to add checkboxes into the group object. You may make multiple calls to this function, and/or pass multiple arguments. You may specify field names exactly, or use a wildcard at the beginning or end of the name.
myOptions.addToGroup("cb1","cb2","optionset*");
myOptions.addToGroup("*checkbox");
Using A Control BoxIf your group has a control box, for example "select all", its name needs to be explicitly set.
myOptions.setControlBox("masterCheckboxName");
There are two ways that a control box can interact with the group - either "all" mode or "some" mode.
myOptions.setMasterBehavior("some");
Restricting Check CountYou may set the maximum number of boxes in the group which are allowed to be checked by using the setMaxAllowed method. You may pass a second argument which is an alert message to be displayed to the user if they exceed this limit. myOptions.setMaxAllowed(2); myOptions.setMaxAllowed(3,"You may only select 3 choices!"); Adding onClick Handlers To CheckboxesAfter defining the group and behavior, you must insert an action into EVERY checkbox's onClick event-handler. Just specify the name of the group object that the checkbox belongs to, and pass it 'this' as the argument. <INPUT TYPE="checkbox" NAME="cb1" onClick="myOptions.check(this)"> |
|||||
All Contents Copyright © Matt Kruse |
|||||