• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

PDF dropdown menu percentage calculation

New Here ,
Sep 29, 2024 Sep 29, 2024

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.

TOPICS
Create PDFs , JavaScript , PDF forms

Views

142

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 29, 2024 Sep 29, 2024

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 29, 2024 Sep 29, 2024

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 29, 2024 Sep 29, 2024

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 01, 2024 Oct 01, 2024

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 01, 2024 Oct 01, 2024

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 01, 2024 Oct 01, 2024

Copy link to clipboard

Copied

I have finally made it work. Thank you very much!

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 29, 2024 Sep 29, 2024

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;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 01, 2024 Oct 01, 2024

Copy link to clipboard

Copied

LATEST

Thank you!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines