These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Form calculations not working

tddirks
Registered: May 7 2009
Posts: 13

I apologize in advance for being a novice here, but I have a tight deadline (today), and my frustration with Acrobat is getting the best of me. Here's what I'm trying to do. I have a form with a grid of text fields that require the user to input 2 to 3-digit number. From those fields, I am trying to calculate the average value of all number entered, which works fine. I also want to calculate the Minimum and Maximum value, then divide the Maximum by the Minimum. Sounds simple enough.

So this is what I've done so far. Created the grid of text fields (about 80 fields total). These fields are formatted as None, since that is the default. I created another text field to use for calculating the Maximum. I used the Calculate tab and selected the "Value is the Maximum.." option at the top, then picked the correct text fields. I formatted this text field as a Number with 1 decimal place. I then did the same for Minimum. Both of these text fields need to be hidden on the form, so I selected the Hidden option for Visibility.

Next, I created another text field to divide the Maximum by the Minimum. The results here also have to be a number with one decimal place. I used simplified field notation with the field names for my minimum and maximum text fields, like this: Maximum/Minimum.

So when I save the form, and open, the form doesn't work. When I enter a number in the text field grid, I get an error message saying the format doesn't match the format of the field used to divide the maximum by the minimum. And in testing the form, I also don't see any values in the Minimum and Maximum fields when I make these visible and enter numbers in the grid.

And to make things worse, if I go back and redo the calculation fields, it appears to work, then after clearing and saving the form, it doesn't.

Any help would be greatly appreciated.

My Product Information:
Acrobat Standard 8.1, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
To debug this issue, change the format of the field with the division result to "None". This will let you see the results which most likely be "NaN", Not a Number, or one of the "Infinity" strings. Since the "Simplified field noation" calculation will not suport logical control statments, you will need to create a "Customized calculation script" to avoid division by zero.

George Kaiser

tddirks
Registered: May 7 2009
Posts: 13
I have tried changing the format to None, and have seen both of those messages. As I said, I'm a newbie to Acrobat and JavaScript, so I don't know how to create the customized calculation script. What has me stumped is why this appears to work, and then doesn't.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
The following can be used:
event.value = ""; // clear field value// get field values as a variablevar divisor = this.getField("Maximum").value;// perform division only if divisor is non zere and a numberif(divisor != 0 & !(isNaN(divisor))  ) {var dividend = this.getField("Minimum").value;event.value = dividend / divisor;}

George Kaiser

tddirks
Registered: May 7 2009
Posts: 13
Thanks. I'll try this when I get back to my office.