Skip to main content
Participant
Sep 15, 2025 5:40 PM UTC
Answered

Count Radio Buttons & show which choice is selected more

Hi all. I'm working on updating an informal assessment for my work (special education teacher here) and trying to make it digital-friendly. It's fairly simple, with a consistent format: 4 sections, each with 11 either/or questions that need to be tallied. I've got the Raido Buttons setup already, but I'd like to see if there's a way to automatically add up which of the 2 options for each question has more selections, and then display that option (not the total) - I.E., if option 1 is chosen more, then that column's name will be returned. Is this possible?

try67
try67Correct answer
Community Expert
Sep 15, 2025 8:07 PM UTC

Yes, it is, using a script. Let's say the fields are named Group1 to Group11, and the options are Choice1 and Choice2 (which is also the value you want to display, if that column is selected the most). You can then do it using this custom calculation script on the text field where the result should appear:

 

var total1 = 0;
var total2 = 0;
for (var i=1; i<=11; i++) {
	var f = this.getField("Group"+i);
	if (f.valueAsString=="Option1") total1++;
	else if (f.valueAsString=="Option2") total2++;
}
if (total1==0 && total2==0) event.value = ""; // Nothing selected
else if (total1==total2) event.value = "Option1, Option2"; // Both options are selected equally
else if (total1>total2) event.value = "Option1"; // There's more of Option1
else if (total1<total2) event.value = "Option2"; // There's more of Option2


12 replies

Participant
Oct 13, 2025 8:56 PM UTC

This thread has useful answers

Translate
mLira222Author
Participant
Oct 13, 2025 9:00 PM UTC

Yes, I did reply to the person who posted the solution above. It did work for me. 

Translate
Participant
Oct 7, 2025 6:10 PM UTC

Yes, it is possible

Translate
Participant
Oct 13, 2025 8:43 PM UTC

but I dont know how to do it

Translate
JR Boulay
Community Expert
Community Expert
Sep 18, 2025 5:08 PM UTC

[MOVED TO THE ACROBAT PRO DISCUSSIONS]

Translate
Acrobate du PDF, InDesigner et Photoshopographe
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Sep 15, 2025 8:07 PM UTC

Yes, it is, using a script. Let's say the fields are named Group1 to Group11, and the options are Choice1 and Choice2 (which is also the value you want to display, if that column is selected the most). You can then do it using this custom calculation script on the text field where the result should appear:

 

var total1 = 0;
var total2 = 0;
for (var i=1; i<=11; i++) {
	var f = this.getField("Group"+i);
	if (f.valueAsString=="Option1") total1++;
	else if (f.valueAsString=="Option2") total2++;
}
if (total1==0 && total2==0) event.value = ""; // Nothing selected
else if (total1==total2) event.value = "Option1, Option2"; // Both options are selected equally
else if (total1>total2) event.value = "Option1"; // There's more of Option1
else if (total1<total2) event.value = "Option2"; // There's more of Option2


Translate
mLira222Author
Participant
Sep 15, 2025 8:24 PM UTC

Okay, so the value I want to display is a single letter. I've updated the choices for each group to show the letter choices I want to display (let's say A and B). There won't be an even selection, so I removed that part of the script, and I've updated the Group names in the script, but it's not showing in the Text field. Do I need to list every field in the GetField section? If so, how do I arrage them? Would they all be within the () or do I repeat the entire line for all 11 questions?


Thanks for your help so far!

Translate