Skip to main content

getValue()

returns the current value/state of a Checkbox control

getValue(): string | boolean;

Returns:

Either a string with the current value of the control or boolean value with the state of the control.

Example

// returns value if the value is specified for the checkboxvar value = form.getItem("checkbox").getValue(); // -> "checkbox_value"
// returns state if the value is not specified for the checkboxvar state = form.getItem("checkbox").getValue(); // -> true/false
  • If the value property is not set for a control, the method returns the state of the control:
var form = new dhx.Form("form_container", {    rows: [        {               type: "checkbox",            label: "I agree",            name: "agree",            id: "agree",            checked: true         }    ]});
var state = form.getItem("checkbox").getValue(); // -> true/false
  • If the value property is defined, the method returns a string value. In addition, if the checked option is set to true, the method returns the value of a control, otherwise - returns an empty string (""):
var form = new dhx.Form("form_container", {    rows: [        {               type: "checkbox",            label: "I agree",            name: "agree",            id: "agree",            checked: false, /*!*/            value: "checkbox_value" /*!*/        }    ]});
var value = form.getItem("checkbox").getValue(); // -> ""