From checkbox group to dropdown box

Hi everyone,

I have a checkbox group where the user chooses multiple answers.
I need that these entries can then be filtered individually in a dropdown box. Do you have suggestions please?

Thanks in advance, as always.

Marco,

If I understand correctly what you’re trying to do, you will need to loop through the selectedIndices of the checkbox group and then populate the dropdown in code based on those checked items (selectedIndices) of the checkbox group.

https://www.wix.com/corvid/reference/$w.CheckboxGroup.html#options
https://www.wix.com/corvid/reference/$w.CheckboxGroup.html#selectedIndices
https://www.wix.com/corvid/reference/$w.Dropdown.html#options

Hi #anthonyb
Yes you understand corrctly, but can you, please, help me with example of code because I’am a beginner with code.

Thank You

@info60119 This should get you there. It’s re-populating the dropdown every time another checkbox group item is checked or unchecked. You might be better off having a button execute the code.

export function checkboxGroup1_change(event) {

let CheckedItems = $w(“#checkboxGroup1”).selectedIndices;
let checkboxValue = “”, dropdownValues = , dropdownItem = {};
if (CheckedItems.length > 0){
for ( var i = 0; i < CheckedItems.length; i++) {
checkboxValue = $w(‘#checkboxGroup1’).options[CheckedItems[i]].value;
dropdownItem = {“label”: checkboxValue,“value”:checkboxValue}
dropdownValues.push(dropdownItem);
}
$w(‘#dropdown1’).options = dropdownValues;
}
}