Cascading buttons on input form


I need to create a input form based on node red. The form need to contain about 4 groups of buttons. When selecting a button in group 1 the buttons in group 2 changes and then group 3 changes based on group 2. Something like cascading dropdowns but with buttons instead I guess. The hierarchy of buttons is based on a resultset from a database. I probably need to do some clientside computing to filter the buttons on change. The submit can only happen when form is fulfilled.

The result is to be stored in a db.

Any good idea on how to achieve this?

Kind regards