Powered by SmartDoc

CKCheckbox

Creates a checkbox. This element must be used within CKForm or HTML form.

Required attributes: selectionand value, or checked

Attributes of CKCheckbox
Attribute Type Description
checked true/false If neither valuenor selectionattribute is nil and the value of selectionis equal to that of value, the check box is checked.
value String When the check box is checked, the value of valueattribute is set to the component by the method specified by selectionattribute.
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 checkedattribute. The other is the way to use both selectionand valueattributes.

checked attribute

If you use checkboxes with checkedattribute, 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.

value and selection attributes

Another usage of CKCheckbox is combination with selectionand valueattributes. selectionattribute is substituted value of valueattribute when a checkbox clicked. Checkboxes turn on if values of selectionand valueattributes 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