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

Pdf form using hidden page template needs to calculate all subtotals (first and spawned pages)

Community Beginner ,
Jan 04, 2021 Jan 04, 2021

Copy link to clipboard

Copied

This is my first foray into using page templates in Acrobat. I have a form that has one nonrepeating page (first page) and one repeating page (hidden page template). The first page has a 'Total of all values' field that needs to calculate the sum of all 'Subtotal' fields contained on all pages, including the first page and all spawned pages. Please see the attached sample form (simplified version).

Just an FYI, my javascript skills are limited.

Any help in this matter is greatly appreciated.

 

TOPICS
JavaScript , PDF forms

Views

542

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 , Jan 05, 2021 Jan 05, 2021

This script makes the total of all text fields containing the word "Value" in their name:

 

var count = 0;
for (var i = 0; i < this.numFields; i++) {
var oFld = this.getField(this.getNthFieldName(i));
if (/Value/.test(oFld.name) && oFld.type == "text") {
count = count + Number(oFld.value);
}
}

event.value = count;

 

It is in the red field, as a calculation script, on page 4: https://documentcloud.adobe.com/link/track?uri=urn:aaid:scds:US:233eb4ee-04f4-404a-bd3a-6889c6ffb3f5

Votes

Translate

Translate
Community Expert ,
Jan 05, 2021 Jan 05, 2021

Copy link to clipboard

Copied

This script makes the total of all text fields containing the word "Value" in their name:

 

var count = 0;
for (var i = 0; i < this.numFields; i++) {
var oFld = this.getField(this.getNthFieldName(i));
if (/Value/.test(oFld.name) && oFld.type == "text") {
count = count + Number(oFld.value);
}
}

event.value = count;

 

It is in the red field, as a calculation script, on page 4: https://documentcloud.adobe.com/link/track?uri=urn:aaid:scds:US:233eb4ee-04f4-404a-bd3a-6889c6ffb3f5

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 Beginner ,
Jan 05, 2021 Jan 05, 2021

Copy link to clipboard

Copied

LATEST

Thank you JR Boulay for your quick response.

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