Clear Select2 dropdown values based on checkbox action

Hi,

Using Bubble to create an app and discovered the Select2 Multi-Select dropdown plug-in.

Use Case: When the user checks a checkbox, a Select2 multi-select dropdown input appears below the checkbox with the appropriate list of choices. When the user makes a selection from the dropdown, a repeating group displays data exactly as I expect. However, when I uncheck my checkbox, the Select2 dropdown retains the last selected value. By the way, I have max selections for this Select2 dropdown set to 1. Is there a way to clear the selection in my Select2 dropdown when I uncheck my checkbox?

Use Case Steps:

  1. User checks the checkbox
  2. Select2 dropdown appears (choices include black, green, white)
  3. User chooses White
  4. Repeating group displays the expected set data
  5. User now UNCHECKS the checkbox… the Select2 dropdown is hidden… but still contains the value “White”. I want the value “White” to be cleared when checkbox is UNCHECKED.

Appreciate any help the community is able to provide.

Thanks

You can programmatically control the Select2’s value. You’ll need to add an event handler to your checkbox that calls this code when the checkbox is unchecked.