Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

multi-cell calculations

New Here ,
Oct 13, 2019 Oct 13, 2019

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

2.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Oct 13, 2019 Oct 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;

 

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2019 Oct 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2019 Oct 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2019 Oct 13, 2019
Is there a "0" before "2cd" or not?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2019 Oct 13, 2019
Yes 02cd1.1 to 02.cd1.135
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2019 Oct 13, 2019
Is there a period after "02" or not?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2019 Oct 13, 2019
Yes 02 a 06
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2019 Oct 13, 2019
Sorry, I don't understand. I thought the only variant was the last number... You need to better describe it, as it's crucial to the code.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2019 Oct 13, 2019
I will use several variables, but I need to understand how I should do to calculate, I can even forward a copy of the document for you to understand better.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2019 Oct 13, 2019
If the names of the fields are not consistent then you'll need to use an array with the literal names of all the fields to make it work. If the field names are consistent then a much simpler approach can be used. Having the file will not help if I don't know which fields you want to test.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2019 Oct 13, 2019
I can rename everyone to a cd.1.1 to cd.1.135 sequence for ease without any problem.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2019 Oct 13, 2019
In that case you could use this code as the custom calculation script of the field that shows the total number of "C" items:
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2019 Oct 13, 2019
Damn it, I hate these forums... Will post the code in a new top-level reply.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2019 Oct 13, 2019
LATEST
Dear Try67 Thank you so much for your effort, time and dedication. Your method worked perfectly. Congratulations
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 13, 2019 Oct 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 13, 2019 Oct 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.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 13, 2019 Oct 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;

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines