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

multi-cell calculations

New Here ,
Oct 13, 2019 Oct 13, 2019

Copy link to clipboard

Copied

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

Views

1.4K

Translate

Translate

Report

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

correct answers 1 Correct answer

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;

 

Votes

Translate

Translate
Community Expert ,
Oct 13, 2019 Oct 13, 2019

Copy link to clipboard

Copied

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

 

What are the names of these fields?

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Is there a "0" before "2cd" or not?

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Yes 02cd1.1 to 02.cd1.135

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Is there a period after "02" or not?

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Yes 02 a 06

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

I can rename everyone to a cd.1.1 to cd.1.135 sequence for ease without any problem.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Damn it, I hate these forums... Will post the code in a new top-level reply.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

LATEST
Dear Try67 Thank you so much for your effort, time and dedication. Your method worked perfectly. Congratulations

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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;

 

Votes

Translate

Translate

Report

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