0

I would like to get the label(s) of the selected values of a checkboxgroup component.

<aura:component>
    <aura:attribute name="options" type="List" default="[{'label': 'Ross', 'value': 'option1'},
                                                         {'label': 'Rachel', 'value': 'option2'},
                                                        ]"/>
    <aura:attribute name="value" type="List" default="option1"/>
    <lightning:checkboxGroup aura:id="mygroup"
                             name="checkboxGroup"
                             label="Checkbox Group"
                             options="{! v.options }"
                             value="{! v.value }"
                             onchange="{! c.handleChange }"
                             required="true" />
</aura:component>

For this example, is there a way where I can also get the label (Ross, Rachel) when selected.

  • 1
    If you want to perform action based on Label then you can simply change option1 to Ross and option2 to Rachel. i.e. <aura:attribute name="options" type="List" default="[ {'label': 'Ross', 'value': 'Ross'}, {'label': 'Rachel', 'value': 'Rachel'}, ]"/> – sfdc_sk Feb 18 at 6:26
  • in the handleChange method you can use var changeValue = event.getParam("value"); to get the value, please check also if you can use var changeValue = event.getParam("label"); to get the label. – Itai Shmida Feb 24 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.