Metro-UI-CSS icon indicating copy to clipboard operation
Metro-UI-CSS copied to clipboard

Dynamically adding optgroups and options from multiple arrays or nested objects from javascript/jquery

Open Seanyap90 opened this issue 3 years ago • 1 comments

Hello I will like to bring your attention to this topic.

Code is here: https://jsfiddle.net/kaqgw6uv/

I am looking to do a dropdown to have options from 2 different categories: dogs and cats so that a user is able to select pets from either one. I want to create this dynamically using javascript as eventually the data will be from a spreadsheet or json.

Currently, the code can only show either dogs or cats, while I have separate arrays representing dogs and cats.

How to solve?

Seanyap90 avatar Jun 26 '22 00:06 Seanyap90

Basically, I don't think you can currently edit selects in JS and use optgroup...

5c0rp264 avatar Aug 28 '23 19:08 5c0rp264