I have a long multi-pages webform with mostly different groups of questions as radios, checkboxes, and likert types. I use computed_twig on some and jQuery on others for mostly either counting (how many of certain options/keys are selected) or summing up (the sum of keys values) selected values.
What's the most efficient strategy I can use and stick to so I can use less code/ re-use my code and need less re-coding for each group of questions (either with computed_twigs and/or jQuery).
The yaml code at this question is one example of my webform wizard pages.
And this is another sample/example where I need to count the number of all selected options of each name (e.g. how many "a" selected and how many "b"):
abqs:
'#type': wizard_page
'#title': 'test options length/count'
'#open': true
ab_1:
'#type': radios
'#title': 'choose one'
'#options':
a: a....
b: b....
'#options_display': buttons
'#required': true
ab_2:
'#type': radios
'#title': 'choose one'
'#options':
a: a....
b: b....
'#options_display': buttons
'#required': true
ab_3:
'#type': radios
'#title': 'choose one'
'#options':
a: a....
b: b....
'#options_display': buttons
'#required': true
ab_4:
'#type': radios
'#title': 'choose one'
'#options':
a: a....
b: b....
'#options_display': buttons
'#required': true
ab_5:
'#type': radios
'#title': 'choose one'
'#options':
a: a....
b: b....
'#options_display': buttons
'#required': true
abscore:
'#type': computed_twig
'#title': 'Selected a/b Counts'
'#template': |-
{# have yet to solve #}
'#ajax': true
'#store': true