doctype [?][strict] [loose] [none]
Check Box Groups
Including The Script
Include a reference to the js file in the HEAD of your HTML page.
Creating The Object
var myOptions = new CheckBoxGroup();
Adding Checkboxes To The Group
Use 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.
Using A Control Box
If your group has a control box, for example "select all", its name needs to be explicitly set.
There are two ways that a control box can interact with the group - either "all" mode or "some" mode.
Restricting Check Count
You 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 Checkboxes
After 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|