• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 517
  • Last Modified:

Total Number of Items Calculation script in Acrobat

I am playing about with Acrobat 8 Pro to create a working Purchase Requisition that will calculate values automatically.

One feature I would like to explore is the ability to sum up how many items have been added to a list up to a total of 10.

The fields I need counted are named 'Item_1" "Item_2" etc up to "Item_10" and using a calculation on the field "Total_Items" I would like a count of all of the item fields with info in them.

Is this at all possible?
0
ultra-it
Asked:
ultra-it
  • 2
1 Solution
 
Karl Heinz KremerCommented:
That's definitely possible. Are you using AcroForm or Designer forms?
0
 
ultra-itAuthor Commented:
I am using AcroForm.
0
 
Karl Heinz KremerCommented:
Open the property dialog for your "Total_Items" field and select the "Calculate" tab. Select a custom calculation script and use the following JavaScript (if you have more than 10 fields, you will have to adjust the loop):
var total = 0;
for (var i=1; i<=10; i++)
{
    var name = "Item_" + i;
    var f = this.getField(name);
    if (f.value.length > 0)
    {
        total++;
    } 
}

event.value = total;

Open in new window

0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now