One way to do is using some JS framework like React, Angular or VueJS.
(VueJS will be the easiest)
Basically, you store all your options in an array or list, and you have different variables for the different configuration options. Your Js program (let’s call it your controller), all has to worry about is updating the values in your variables, and if there are business logic/rules governing those variables. Example: if VariableA contains X value, then VariableB is required or VariableB can have Y or Z values only.
On the front end, depending on what those variable values are, the appropriate select box, or radio options can be highlighted or marked as selected. So on the front end, you just apply some CSS rules based on the value of the corresponding variable.
When users pick certain options, the appropriate variables are updated with new values. Then the controller applies whatever business logic is needed, then the front end View is updated again.
For example, when I made the Random Quote generator, all my JS program does when the user clicks the button is generate a new random number and assign the new value to ‘ndx’
generateNewQuote: function(){
this.ndx = parseInt(Math.random() * this.quotes.length);
}
that’s it.
And on my webpage, all my HTML does is display the appropriate entry in the array depending on the value of ‘ndx’… all done automatically.
<i>{{ quotes[ndx].person }}</i>
That’s it.
The VueJS framework will then fill in everything in between the {{ }} with the correct array value.
My JS code does not manually update the text in the HTML. It doesn’t care how the HTML page is constructed. All my JS code takes care of is updating the variable value.
https://randomquote-owel.surge.sh/