Copy link to clipboard
Copied
Hi, I am trying to create a PDF invoice form, with fields that calculate 9% tax and 21%tax.
If I have both fields in the form then the "total" field adds both values. So I thought to would create a dropdown field that would specify if the btw in the invoice is 9% or 21% and then only the required amount will be displayed in the "Tax" field.
I cannot find the JavaScript that would allow me to do that.
Could anyone help me, please?
Thank you.
Copy link to clipboard
Copied
If you just want to show the value of dropdown in tax field, use this as 'Validate' script of dropdown field:
this.getField("Tax").value = event.value;
If you need to actually calculate tax, let us know.
Copy link to clipboard
Copied
Hi Nesa,
Thank you for a quick reply.
Ideally, if I select 9% in the drop menu, it would calculate 9% from the "subtotal" field and show the result in the "Tax" field. (same if I select 21%).
Copy link to clipboard
Copied
What is the name of the dropdown field, and what are exact values in dropdown "9%" or "9" and do you have set export value?
Copy link to clipboard
Copied
Hi, thank you, for some reason, I still could not make it work.
The Dropbox field is called "Tax%". The field that should show the calculated amount it "Tax".
If I choose 9% in the dropdown it should calculate 9% of the sum in the field "Subtotal".
If I choose 21% in the dropdown it should calculate 21% of the sum in the field "Subtotal"
Then the "Total" field can add "Subtotal" and the "tax".
Thank you.
Copy link to clipboard
Copied
You can follow @PDF Automation Station solution, just change field names in the script "TaxDropdown" to "Subtotal" and "Tax" to "Tax%" and place the script in "Tax" field under 'Calculate' tab as custom calculation script.
Or you can also try to use simplified field notation in "Tax" field by entering this: Subtotal*Tax\% (after you set export values).
Copy link to clipboard
Copied
I have finally made it work. Thank you very much!
Copy link to clipboard
Copied
In the options tab of the dropdown add enter 9% as an item and .09 as it export value, then 21% as an item and .21 as its export value. In the tax field enter the following custom calculation script:
event.value=this.getField("TaxDropdown").value * this.getField("Tax").value;
Copy link to clipboard
Copied
Thank you!