Skip to main content
Participant
September 15, 2025
Answered

Count Radio Buttons & show which choice is selected more

  • September 15, 2025
  • 4 replies
  • 372 views

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?

Correct answer try67

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


4 replies

Participant
October 13, 2025

This thread has useful answers

mLira222Author
Participant
October 13, 2025

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

Participant
October 7, 2025

Yes, it is possible

Participant
October 13, 2025

but I dont know how to do it

JR Boulay
Community Expert
Community Expert
September 18, 2025

[MOVED TO THE ACROBAT PRO DISCUSSIONS]

Acrobate du PDF, InDesigner et Photoshopographe
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
September 15, 2025

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


mLira222Author
Participant
September 15, 2025

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!