Creates a checkbox. This element must be used within CKForm or HTML form.
Required attributes: selection
and value
, or checked
Attribute | Type | Description |
---|---|---|
checked |
true/false |
If neither value nor selection attribute is nil and the value of selection is equal to that of value , the check box is checked. |
value |
String |
When the check box is checked, the value of value attribute is set to the component by the method specified by selection attribute. |
selection |
Array |
Object that the user chose from the check box. |
enabled |
true/false |
If the value is false, the element appears but is not active. |
You use this element in two ways. One it the way to use checked
attribute. The other is the way to use both selection
and value
attributes.
If you use checkboxes with checked
attribute, the checkboxes are controlled with on/off.
<cgikit name=Form> <cgikit name=Checkbox1>One</cgikit> <cgikit name=Checkbox2>Two</cgikit> <cgikit name=Checkbox3>Three</cgikit> <cgikit name=Submit/> </cgikit>
Form : CKForm { } Checkbox1 : CKCheckbox { checked = checkedOne; } Checkbox2 : CKCheckbox { checked = checkedTwo; } Checkbox3 : CKCheckbox { checked = checkedThree; } Submit : CKSubmitButton { }
class Checkbox < CKComponent attr_accessor :checkedOne, :checkedTwo, :checkedThree end
The variables are substituted true when the checkboxes clicked.
Another usage of CKCheckbox is combination with selection
and value
attributes. selection
attribute is substituted value of value
attribute when a checkbox clicked. Checkboxes turn on if values of selection
and value
attributes are equal.
<cgikit name=Form> <cgikit name=Checkbox1>One</cgikit> <cgikit name=Checkbox2>Two</cgikit> <cgikit name=Checkbox3>Three</cgikit> <cgikit name=Submit></cgikit> </cgikit>
Form : CKForm { } Checkbox1 : CKCheckbox { value = "One"; selection = checkedOne; } Checkbox2 : CKCheckbox { value = "Two"; selection = checkedTwo; } Checkbox3 : CKCheckbox { value = "Three"; selection = checkedThree; } Submit : CKSubmitButton { }
class Checkbox < CKComponent attr_accessor :checkedOne, :checkedTwo, :checkedThree end