How to update two dropdowns dynamically

How to configure two dropdown options so that when the user selects a value in one of the dropdowns, the options of the second dropdown are automatically updated, filtering according to what is selected in the first dropdown?