# Multiple Select Dropdowns Not Working Correctly

**URL:** https://community.feathery.io/t/multiple-select-dropdowns-not-working-correctly/568
**Category:** Support
**Created:** [March 24, 2024, 5:35pm UTC](https://community.feathery.io/t/multiple-select-dropdowns-not-working-correctly/568 "2024-03-24T17:35:06Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Beplace](https://avatars.discourse-cdn.com/v4/letter/b/8e8cbc/32.png) [@Beplace](https://community.feathery.io/u/Beplace)
#### Post date: [March 24, 2024, 5:35pm UTC](https://community.feathery.io/t/multiple-select-dropdowns-not-working-correctly/568/1 "2024-03-24T17:35:06Z")

</div>

We currently have the following code - FYI there are hundreds of these conditions:

if (feathery.fields[‘a’].equals(‘Apple’))  
feathery.fields[‘c’].options = [‘Carrot’,‘Cashew’];

if (feathery.fields[‘a’].equals(‘Apricot’))  
feathery.fields[‘c’].options = [‘Cherry’,‘Cantaloupe’];

if (feathery.fields[‘a’].equals(‘Avocado’))  
feathery.fields[‘c’].options = [‘Cabbage’,‘Cucumber’];

if (feathery.fields[‘a’].equals(‘Asparagus’))  
feathery.fields[‘c’].options = [‘Celery’,‘Corn’];

Field A and Field C are both multi select drop-downs.

Currently, when any value is selected in Field A, then the last selected value renders the available dropdown values for Field C.

How do we adjust the code so that if any combination of Apple, Apricot, Avocado, or Asparagus are selected in Field A, then C renders all of the corresponding dropdown values? (FYI The actual code has hundreds of Field A values and thousands of corresponding Field C values).

---

<div class="post-metadata">

### Author: ![summep](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@summep](https://community.feathery.io/u/summep)
#### Post date: [March 24, 2024, 6:26pm UTC](https://community.feathery.io/t/multiple-select-dropdowns-not-working-correctly/568/2 "2024-03-24T18:26:32Z")

</div>

You can use Javascript’s includes method ([documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes)).

```auto
if (a.value.includes('Apple') && a.value.includes('Apricot')) {
  c.options = ['Carrot', 'Cashew', 'Cherry', 'Cantaloupe']
}

```

Is [this post](https://community.feathery.io/t/multiple-condition-javascript-logic/567) also asking about the same thing? Thank you.

---

<div class="post-metadata">

### Author: ![Beplace](https://avatars.discourse-cdn.com/v4/letter/b/8e8cbc/32.png) [@Beplace](https://community.feathery.io/u/Beplace)
#### Post date: [March 24, 2024, 7:29pm UTC](https://community.feathery.io/t/multiple-select-dropdowns-not-working-correctly/568/3 "2024-03-24T19:29:37Z")

</div>

This answers the question for the other post but not this post. See the revised question above for better context.

---

<div class="post-metadata">

### Author: ![summep](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@summep](https://community.feathery.io/u/summep)
#### Post date: [March 24, 2024, 7:56pm UTC](https://community.feathery.io/t/multiple-select-dropdowns-not-working-correctly/568/4 "2024-03-24T19:56:44Z")

</div>

You would use the same logic but adjust the combinations in the `if` statement and set different combinations for `c.options`. For a large number of conditions, you might want to optimize it to handle multiple combinations. You can consider doing this through a mapping object, [Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map) or [Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set). We recommend exploring more JavaScript documentation and resources on managing complex conditions and data structures efficiently.

---

<div class="post-metadata">

### Author: ![Beplace](https://avatars.discourse-cdn.com/v4/letter/b/8e8cbc/32.png) [@Beplace](https://community.feathery.io/u/Beplace)
#### Post date: [March 24, 2024, 8:03pm UTC](https://community.feathery.io/t/multiple-select-dropdowns-not-working-correctly/568/5 "2024-03-24T20:03:16Z")

</div>

Is there a simple way of doing this using the .includes function? For example, rather than allocate for all of the combinations, something to the effect that if Field A includes any value, then Field C would include the combination of all of the corresponding values.

---

<div class="post-metadata">

### Author: ![summep](https://avatars.discourse-cdn.com/v4/letter/s/9dc877/32.png) [@summep](https://community.feathery.io/u/summep)
#### Post date: [March 24, 2024, 8:42pm UTC](https://community.feathery.io/t/multiple-select-dropdowns-not-working-correctly/568/6 "2024-03-24T20:42:54Z")

</div>

As mentioned you can explore different data structures to manage this efficiently.
