I need help with filtering out select box options. I have selection box like this one

  <select id="food-category">
  <option value="Fruits">Fruits</option>
  <option value="Vegetables">Vegetables</option></select>

<select id="food-subcategory">
  <option value="Bananas">Banana</option>
  <option value="Kiwis">Kiwi</option>
  <option value="Asparagus">Asparagus</option>
  <option value="Carrot">Carrot</option>

I’m trying to filter the options in the second select box based on the chosen options in the first one.

I’ve found a similar question How to filter select options with jQuery? which has an answer that works well if the second option values are name-related to the first ones, but in my case, these are completely unrelated.

So if I select

in the first one, I want to have
as available options in the second one.

I appreciate any help!

Anonymous Asked question May 14, 2021