WB
Web Bae•13mo ago
Anish

Select Option Attribute

What's the best way to add attribute to select field options ?
4 Replies
Web Bae
Web Bae•13mo ago
Hey @Anish you can do this with javascript but without an example I don't know what else to advise here.
Anish
Anish•13mo ago
Hey @Web Bae So, I have a select field where first option is "How can we help you?" I'm looking for a way to not show it when select field is clicked.
No description
No description
Web Bae
Web Bae•13mo ago
Thanks for the clarification @Anish Since "How can we help you?" is in the options list, it will always show in the open menu. Usually when I see this style of select, people give that first option the selected and the disabled along with the required attributes. This shows it as the main option but doesn't allow the user to submit the form until a different option is chosen. If you really need to remove it from the display list you'd need to code your own select, which is not trivial esp. to include accessibility and everything you get with the default component. Some libraries are available as well as Finsweet Select but I'm not sure is provides an option for the behavior you are looking for.
Anish
Anish•13mo ago
Makes Sense @Web Bae ! Thanks 🙌
Want results from more Discord servers?
Add your server