How can I create a dependent option set using Javascript in Dynamics 365 v8.2 on-premise?

Hi Everyone,

Our use case is we have two option sets. Both can be modified by the user. Optionset1 contains two values. Optionset2 contains a dozen values. We want Optionset2 to show values depending on what value is selected for Optionset1.

When no value is selected for Optionset1, we want Optionset2 to show no values (or be disabled).

We want the user to be able to change values for Optionset1 multiple times during the same session if necessary and always get the corresponding values for Optionset2.