Skip to main content
Participant
September 29, 2024
Question

PDF dropdown menu percentage calculation

  • September 29, 2024
  • 2 replies
  • 1012 views

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.

This topic has been closed for replies.

2 replies

PDF Automation Station
Community Expert
Community Expert
September 29, 2024

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;

Participant
October 1, 2024

Thank you!

Nesa Nurani
Community Expert
Community Expert
September 29, 2024

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.

Participant
September 29, 2024

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%).

Nesa Nurani
Community Expert
Community Expert
September 29, 2024

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?