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

calculations

haley
Registered: Jul 15 2010
Posts: 38

well here I am again. I have tried and tried to figure out the calculation scripts provided to me but with no luck.

Here is my problem:

1. Gross Direct $__________
2. Deductions
credits $ _____
creditor $ _____
other $ _____
Total deductions ______

3. Total taxable (deduct 2 from 1) $ (I have figured out the subtraction
script for the deduction of 2 minus 1)

4. Tax payable at 1.25% of item 3 $ (this is the script I am having difficulty
with. I cannot figure out how to do a
script for this amount-I have tried the
suggestions received but does not
seem to work).

I have done the forms in PDF - did not use LiveCycle.

try67
Expert
Registered: Oct 30 2008
Posts: 2398
If the name of the Total taxable field is "Total taxable", enter this as the custom calculation code for 4:
event.value = this.getField("Total taxable").value * 0.0125;
Also, make sure that the form calculation order is 1 then 2 then 3 then 4.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
There are a number of ways to do this. But first, let us review the relationship between a percentage number and a decimal number. A percentage number is a decimal number multiplied by 100, so if I have 1.25% that number is the same as 0.0125, and when you perform a tax calculation for computing a sales tax of 1.25% times a total taxable amount, one multiplies the total taxable amount by 0.0125.

If you are going to cut and paste provided JavaScript and you are going to change a field name only change the text for the field name between the quotation marks. All character strings begin and end with quotation marks and the quotation marks must be matched pairs. Also you have to use a very simple text editor that does not do any special formatting like Window's NotePad or Acobat's builtin editor.

There are a couple of ways you can accomplish this using the techniques described in [url=http://www.acrobatusers.com/tutorials/2006/form_calculations]How to do (not so simple) form calculations[/url] by Thom Parker.

First you need to have a couple of form fields. So assuming you field names are as follows:

TotalTaxable for the "Total Taxable Amount"

TaxRate for the Sales Tax Rate formatted as a percentage with a default value of 0.0125 - note that JavaScript is treat this value as if it were multiplied by 100 for display and use the default value of 0.0125 for calculations.

SalesTaxAmount for the amount of sales tax being charged, The Total Taxable Amount times the Sales Tax Rate as a decimal number

For the "SalesTaxAmount" field you can use one of the following calculation options:

For the "Value is the ____ of the following fields:" option:

Select this option. Use the 'Product'
Select the 'TotalTaxable' and 'TaxRate' fields
Click the 'OK' button to lock in the fields.

For the "Simplified field notation" option you can use:
TotalTaxable * TaxRate
or use this code:
TotalTaxable * 0.0125
For the 'Custom calculation script' option you can use:
// change the text between the quotation marks as needed// variable for the total taxable field namevar cTotalField = "TotalTaxable";// variable for the tax rate field namevar cTaxRate = "TaxRate";// make no edits beyond this line// variables for the necessary field valuesvar nTotalField = this.getField(cTotalField).value;var nTaxRate = this.getField(cTaxRate).value;// compute the value of this fieldevent.value = nTotalField * nTaxRate;

or
// change the text between the quotation marks as needed// variable for the total taxable field namevar cTotalField = "TotalTaxable";// variable for the tax rate as a decimal numbervar nTaxRate = 0.0125;// make no edits beyond this line// variables for the necessary field valuesvar nTotalField = this.getField(cTotalField).value;// compute the value of this fieldevent.value = nTotalField * nTaxRate;

George Kaiser

rowelc
Registered: Nov 11 2008
Posts: 5
I am using Acrobat 9 Pro for Macintosh. I created a pdf out of InDesign. I'm trying to make it an interactive/fillable pdf.

Field X
Field Y
Field Z

Field Z would be the result of Field Y being divided by Field X.
All three fields are formatted as a number, decimal places “2,” no currency symbol. Field values are not validated. For Field [Z] in the calculation, I checked “Simplified Field Notation” and entered: Y / X

Field [Z] would be a result of division [Y divided by X]. It calculates correctly, but pop up messages keep appearing all over the document when you try to enter information in other fields that say: The value entered does not match the format of the field [Z]. And then it pops you back to the page with that field on it [Z].

HELP! How can I rectify this problem?
rowelc
Registered: Nov 11 2008
Posts: 5
Need response ASAP. Thank you.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Search the forums for division. You will need a custom JavaScrpt for this calculation.

George Kaiser