Skip to main content

getValue()

returns the current value/state of a checkbox(s)

getValue(id?: string): string | boolean | {[id: string]: boolean | string};

Parameters:

  • id: string - optional, the id of a checkbox

Returns:

If the id of a checkbox is specified, the method returns either a string with the current value of the checkbox, or a boolean value with the state of the checkbox.

If the id of a checkbox is not specified, the method returns an object with the current values/states of checkboxes. The object contains a set of key:value pairs where the key is the id of a checkbox and the value is either the value of a checkbox or its state (if the value attribute is not specified for the checkbox).

Example

// returns string value if the value is specified in the checkbox configuration
form.getItem("CheckboxGroup").getValue("checkbox_id_1"); //-> "some_value"

// returns a boolean state if the value is not specified for the checkbox
form.getItem("CheckboxGroup").getValue("checkbox_id_2"); //-> true/false

// returns an object with the current values/states of checkboxes
form.getItem("CheckboxGroup").getValue();
// -> { "checkbox_id_1": "some_value_1", "checkbox_id_2": true }