I have an Acrobat form that has a 11 x 7 grid of text fields. I want to be able to average the text fields based on the user input in this grid. However, I want to include in the average only those fields in which the user has entered a value. So, for example, if the user only enters a value in three fields of the grid, the average would be the total of those three fields divided by three. Selecting all the fields in the grid and using the "Value is the Average" option of the Calculate tab divides the total of those fields by 77, or the total number of fields in the grid.
I'm assuming that JavaScript would allow me to perform this calculation, though I'm not familiar with JavaScript and have no idea how to create the script for this. In trying to research other scripts similar to what I need, one problem I see is the naming of the fields in the grid. I used the "Place Multiple Fields" option to create the 77 text fields from one field. Thus, I ended up with names of 1Field.0.0 to 1Field.0.10 for the fields in the first row, down to 1Field.6.0 to 1Field.6.10 for the last row. So I'm wondering how a JavaScript For loop can account for this numbering without having to type out the name of every field in the grid in the script.
I also need to find the Maximum and Minimum for only those fields that have user input, but I'm assuming the script for Averaging would be easily modified to handle these calculations.
Any help with the script for this would be greatly appreciated. I'm using Acrobat Windows version 8.1.0, and this is an Acrobat form, not LiveCycle Designer.
This code relies on the "resolveNodes()" function to find the fields, but since I don't know how your form is organized this line may be incorrect. You'll need to fix it up for the specific field organization on your form. The min and max values can be added right into this calculation.
Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]
The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]
Then most important JavaScript Development tool in Acrobat
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window[/b][/url]
Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script