Skip to main content
AlleyCAD
Participant
January 4, 2021
Answered

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

  • January 4, 2021
  • 1 reply
  • 999 views

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.

 

This topic has been closed for replies.
Correct answer JR Boulay

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

1 reply

JR Boulay
Community Expert
JR BoulayCommunity ExpertCorrect answer
Community Expert
January 5, 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

Acrobate du PDF, InDesigner et Photoshopographe
AlleyCAD
AlleyCADAuthor
Participant
January 5, 2021

Thank you JR Boulay for your quick response.