Skip to main content
Participating Frequently
October 13, 2019
Answered

multi-cell calculations

  • October 13, 2019
  • 3 replies
  • 2032 views

I created a form in acrobat with several cells that will have as information the characters "C" or "D". I need to sum up how many of these cells contains "C" and how many contains "D". Already searched in several tutorials and found nothing. Is there any way to perform this calculation?

The fields have names ranging from 2cd1.1 to 02cd1.135.
The information will be: "C" or "D"
I only need to add the fields with the variable "C" and then only the fields with the variable "D", disregarding the empty fields.

Field "tcri" should display total of "c" and field "tdri" should display total of "D"

thanks for the suport

    This topic has been closed for replies.
    Correct answer try67

    You could use this code as the custom calculation script of the field that shows the total number of "C" items:

     

    var total = 0;
    for (var i=1; i<=135; i++) {
    	if (this.getField("cd.1."+i).valueAsString=="C") total++;
    }
    event.value = total;

     

    3 replies

    try67
    Community Expert
    try67Community ExpertCorrect answer
    Community Expert
    October 13, 2019

    You could use this code as the custom calculation script of the field that shows the total number of "C" items:

     

    var total = 0;
    for (var i=1; i<=135; i++) {
    	if (this.getField("cd.1."+i).valueAsString=="C") total++;
    }
    event.value = total;

     

    Inspiring
    October 13, 2019

    I woul fill an array with the values of the fields and then filter that array to only the values of "C" or 'D' and then take the length of the filetered array.

    J R A&SAuthor
    Participating Frequently
    October 13, 2019
    I'm sorry but I'm totally new to this. And I wouldn't know how to solve it like that. If possible I need a script template for the solution. Still, thank you very much.
    try67
    Community Expert
    Community Expert
    October 13, 2019

    This was discussed multiple times in the past, but Adobe removed access to many old threads, unfortunately...

     

    What are the names of these fields?

    J R A&SAuthor
    Participating Frequently
    October 13, 2019
    The fields have names ranging from 2cd1.1 to 02cd1.135. The information will be: "C" or "D" I only need to add the fields with the variable "C" and then only the fields with the variable "D", disregarding the empty fields. Field "tcri" should display total of "c" and field "tdri" should display total of "D" thanks for the suport
    try67
    Community Expert
    Community Expert
    October 13, 2019
    Is there a "0" before "2cd" or not?