I have four questions on UI. User need to select yes or no for each question and save into database. From the below code I am not able to select Yes or No for each question. If I select Yes or not one questions, other questions values are deselecting. How to select multiple checkbox or radio group button in LWC?
HTML:
<lightning-checkbox-group name="Checkbox Group"
label='Event'
options={options}
value={value}
onchange={handleChange}></lightning-checkbox-group>
<p>Selected Values are: {selectedValues}</p>
<lightning-checkbox-group name="Checkbox Group"
label='outsideEvent'
options={options1}
value={value}
onchange={handleChange}></lightning-checkbox-group>
<p>Selected Values are: {selectedValues}</p>
<lightning-checkbox-group name="Checkbox Group"
label='selected?'
options={options2}
value={value}
onchange={handleChange}></lightning-checkbox-group>
<p>Selected Values are: {selectedValues}</p>
JS:
get options() {
return [
{ label: 'Yes', value: 'True' },
{ label: 'No', value: 'false' },
];
}
get selectedValues() {
return this.value.join(',');
}
get options1() {
return [
{ label: 'Yes', value: 'option3' },
{ label: 'No', value: 'option4' },
];
}
get options2() {
return [
{ label: 'Yes', value: 'option5' },
{ label: 'No', value: 'option6' },
];
}
[![enter image description here][1]][1]
[![enter image description here][2]][2]