Bits Extension Methods Library

The "bits" extension library works with "checkbox" and "select box" elements that share the same name. When the browser detects these types of fields, it treats the elements in the field as an array. The "Bit Library" by default assumes that the elements are worth 2 ^ x (where x is the current element array position.)

In the properties and methods below, obj is an abbreviation for the object name you specified when you called the qForm constructor. fieldName signifies the form field element that you want to perform the action on. Arguments in bracket ("[ ]") are optional.

Methods

obj.fieldName.getBits([boolean useValue])
The getBits method will return the sum of all bits currently selected. The getBits() method only works on checkbox fields with the same field name or with multi-select boxes.

The useValue argument is an optional argument used to specify whether or not to use the actual form field's value or to calculate the value based upon the position in the array the item falls in. If set to true, then the value of the form element is used when calculate the integer that represents the binary number. If set to false, then the value of each element checked, will be calculated based upon it's position in the array. (2 ^ x, where x equals the position in the array.)

obj.fieldName.setBits(int value, [boolean useValue])
The setBits() method only works on checkbox fields with the same field name or with multi-select boxes.

The value argument is a required parameter which indicates the value that should be applied to the bit field.

The useValue argument is an optional argument used to specify whether or not to use the actual form field's value or to calculate the value based upon the position in the array the item falls in. If set to true, then the value of the form element is used when determining whether the value should be marked on. If set to false, then the value of each element checked, will be calculated based upon it's position in the array. (2 ^ x, where x equals the position in the array.)

[< Back] [Index] [Next >]