Show and Hide the Choice field's options value

Hi,

I need your assistance in creating a JavaScript script that dynamically shows or hides specific option values in a Choice field based on certain conditions in the New and Edit forms.

Example:
I want to hide the option values "2" and "3" in the Choice field to prevent users from selecting them. However, these options should be enabled under certain conditions.

Thank you!

Hello @Pannir ,

I would be looking for "Dropdown" common field.
With just a piece of JavaScript you can handle the data inside.

Use this - Official Plumsail Documentation - Common field - set data source

fd.field('Field1').widget.dataSource.data(['New option 1', 'New option 2', 'New option 3']);

Do a logic in a function when the number 2 and 3 should and should not appear.

When the dropdown is changed:
Dropdown field is changed - Official Plumsail Documentation

Set the choice field value based on the selection:
Choice field - set value - Official Plumsail Documentation

If you need further assistance, let me know :slight_smile:
(Apply for the newform)

When opening EditForm - you must think about loading the value back to the dropdown. Also in the DispForm, you should only show the Choice field with the value.

Regards
Stepan

1 Like