Use Javascript to hide/disable an option in select

By: Aaron Taylor | Asked: 02/13/2023
ForumsCategory: Code HelpUse Javascript to hide/disable an option in select
Aaron Taylor asked 2 years ago

I've got a large multi step form which contains a lot of select fields. Some of which have common options, one being 'not sure'.

I need to hide/disable this 'not sure' option if a user has selected a specific option in a previous select field.

I've found this which sounds like it's what I need but I don't understand how to apply it to my scenario. Can anyone explain it in simple terms please?

https://formidableforms.com/knowledgebase/javascript-examples/#kb-hide-option-in-select

Thanks!

2 Answers
Rob LeVineRob LeVine answered 2 years ago
It's not clear what level of detail you're looking for here. There's not got to be a plug-n-play solution listed on the FF site for your situation. The code you reference will hide an option of one set of radio buttons (or checkboxes or dropdown). You'll have to add code before that to listen for the change event on the previous select, get the selected value and then run the hide code if it matches your criteria (see here for a similar example). If you're not a developer or don't feel comfortable with jQuery code, you can always reach out to hire a developer.
Aaron Taylor answered 2 years ago

I was hoping for some help if possible. There seems to be similar solutions to my situation therefore I was hoping someone could tell me what code to put where. An alternative maybe, this snippet seems to be what I'm after but it's for a radio button, can it be changed to use with a select field?https://www.fdmdigital.co.uk/slack-code-snippets-part-1/This snippet will show / hide a radio button option based on another radio button value.Thank you.

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right