Skip to main content
ulrikh32139234
Participant
Sep 14, 2018 1:55 PM UTC
Answered

Calculate number of radio groups answered

I have three radio groups rg1, rg2 and rg3 with 6 option in each. I can calculate the sum of the three selection in each radio group easily. But I also need a text field calculation the number of radio groups checked. So if two of the radio groups are answered the text field should show 2. Is it done with a simple java script? And what would it look like?

This topic is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Sep 14, 2018 2:15 PM UTC

Yes, this can be done with the following custom calculation script:

var total = 0;

for (var i=1; i<=3; i++) {
    if (this.getField("rg"+i).valueAsString!="Off") total++;
}

event.value = total;

2 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Sep 14, 2018 2:15 PM UTC

Yes, this can be done with the following custom calculation script:

var total = 0;

for (var i=1; i<=3; i++) {
    if (this.getField("rg"+i).valueAsString!="Off") total++;
}

event.value = total;

Translate
ulrikh32139234
Participant
Sep 14, 2018 4:59 PM UTC

Yes man! works perfectly

Translate