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

Custom calculation of totals

sdwhite
Registered: Nov 3 2010
Posts: 9

I have an Acrobat 9 interactive pdf where a 'total' field displays the sum of dollar amounts from several previous fields. However, if only the first field is filled in, I need to automatically display only that amount in the total, otherwise, I need it to do the prior calculation.
 
I've tried a few things with javascript but am still not too familiar with the language.
 
Any suggestions are welcome and appreciated.
 
Thanks!

My Product Information:
Acrobat Pro 9.0, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
It should do that automatically, unless I'm missing something. If only the first field has a value and the others are blank, the field that displays the total of all of the fields should show the same amount as the first field if it has a value and the others are blank. If it does not, it may be that the field calculation order is incorrect, in which case you should set it to whatever makes sense for your form.
sdwhite
Registered: Nov 3 2010
Posts: 9
George,

Thanks for your help.

After reading your response and doing some more testing, i realized that you are correct except for one more detail that I left out. Sorry.

The summing of totals works except that there are also (conditionally) custom calculations being done to calculate the totals that are later summed to get the grand total.

Let me try to explain the whole thing:

There are 3 columns on this form: 'Total Hours', 'Hourly Rate', and Total Payment'. The product of the 1st 2 equals the third and uses a custom calculation script to ensure no rounding errors and which also has a clause allowing users to enter a flat rate total directly. There are 20 rows like this. Then, the values in the 'Total Payment' column from each row are summed to get the final 'Total' at the bottom of the form.

If I enter a 'Total Payment' amount directly into the 1st row, the amount shows up in the final 'Total' field. But if I enter 'Hours' and 'Rate', the 'Total Payment' that is calculated doesn't appear in the final 'Total'. However, if I enter a 2nd row of data, the calculations all work and the new total DOES appear in the final 'Total' field.

I checked the calculation of the 'Total' field and the first field listed is the first 'Total Payments' field on the form so I'm not sure where things are going south.

Thanks again!

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Have you confirmed that the field calculation order is correct?
sdwhite
Registered: Nov 3 2010
Posts: 9
I have. The first field in the column is the first one in the calculation but I'm going to try renaming things to see what effect that has. Thanks.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
In Acrobat forms you modify the calculation order by Editing the form in Acrobat ("edit => Form in Acrobat") and then setting the field calculation order ("Edit => Edit Fields => Set Field Calculation Order...").Renaming the fields does not change the order of calculation. If no action is taken the form field calculation order is the order in which the fields are created.

George Kaiser

sdwhite
Registered: Nov 3 2010
Posts: 9
Thank you both for your help! I finally got it to work. For some reason, the first field was being calculated LAST!