Copy link to clipboard
Copied
I have searched the posts and tried the code, but I am missing something.
My Grouped Radio Buttons have JavaScript on Mouse Down
this.getField("Yes").value = "1"
this.getField("No").value = "2"
this.getField("NA").value = "3"
My Text Fields has JavaScript for Custom calculation script. The Yes and 1 are changed to No and 2, and NA and 3 for their respective text field.
(function () {
var i, val, sum = 0;
for (var i = 1; i <= 48; i ++) {
val = getField("Group" + i).getField("Yes").value;
if (val == "1") {
sum += +val;
}
}
event.value = sum;
})();
If your fields are named "Group1-48" and their choices are "Yes" "No" and "NA", you can use this as custom calculation script of "Yes" field:
var total = 0;
for(var i=1; i<=48; i++){
if(this.getField("Group"+i).valueAsString == "Yes")
total++;}
event.value = total;
For other fields, just change "Yes" to "No" or "NA".
Copy link to clipboard
Copied
Hi @glstephens08,
Hope you are doing well. Per the description, I understand that you want to calculate the value for radio buttons.
You may refer to the given link to get the complete script for the calculation:
Calculate radio buttons | Adobe Acrobat (acrobatusers.com)
Hope this helps.
-Souvik.
Copy link to clipboard
Copied
Following line makes no sense:
val = getField("Group"+i).getField("Yes").value;
Copy link to clipboard
Copied
I tried it as val = getField("Group"+i).value; and that didn't work either
Copy link to clipboard
Copied
If your fields are named "Group1-48" and their choices are "Yes" "No" and "NA", you can use this as custom calculation script of "Yes" field:
var total = 0;
for(var i=1; i<=48; i++){
if(this.getField("Group"+i).valueAsString == "Yes")
total++;}
event.value = total;
For other fields, just change "Yes" to "No" or "NA".
Copy link to clipboard
Copied
Thank you that worked.