Total Number of Items Calculation script in Acrobat

Posted on 2010-01-05
Last Modified: 2012-05-08
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?
Question by:ultra-it
    LVL 44

    Expert Comment

    by:Karl Heinz Kremer
    That's definitely possible. Are you using AcroForm or Designer forms?

    Author Comment

    I am using AcroForm.
    LVL 44

    Accepted Solution

    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)
    event.value = total;

    Open in new window


    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    The ability to edit PDF documents can be useful, however it may not be a straight forward process. Many non-technical people don't realise that a PDF document is basically an image rather than a text file, even if it contains nothing but text. If…
    Update 21-May-2015: I temporarily removed the source code and the code snippets to make major changes to the program. Regards, Joe INTRODUCTION This Article is a follow-up to the Article entitled How To Rename-Move a Batch of PDF Files Based o…
    In this third video of the Xpdf series, we discuss and demonstrate the PDFtoText utility, which converts PDF files into plain text files. Download and install the software.: You may have already downloaded and installed the Xpdf tools while watching…
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now