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

Script for calculating sales tax on only certain fields

New Here ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

Hello, I am looking to calculate 5% tax on only certain field I have listed below.   The script below calculates 10% and but shows as $14750.00 on a subtotal of $1475.00.  Please help, what am I doing wrong.

 

var a = this.getField("fill_76").value;
var b = this.getField("Full Clean").value;
var c = this.getField("Floors only").value;
if (a !=="" || b !=="" || c !=="") {
event.value = a+b+c*(.05/100);
} else {
event.value ="";
}

TOPICS
How to , JavaScript , PDF forms

Views

975

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
2 ACCEPTED SOLUTIONS
Community Expert ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

The 5% calculation on the sum of the three fields should be:

(a+b+c) * .05

 

 

View solution in original post

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

I think you totally misunderstood my directions on the radio buttons.  You originally had one set of radio buttons for 4 possible answers, now you have 4 separate radio buttons.  You need a Yes/No set for Youth Group and a Yes/No set for Non-Profit.  The export values should be the decimals only, (i.e. .15 and .25), not Choice 1=".25".  Better yet, I wouldn't even use radio buttons.  I would use one check box for Youth Group and another for Non-profit.  The export values will be either .15/.25 when checked, or "Off" when unchecked.

View solution in original post

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

The script you've posted does not calculate 10% of 1450. 

It add as "a", "b", and .05% of "c", i.e., that's .0005 * c

In the form the "b" and "c" values are empty strings, so the value of GST at 5% is the "subtotal", which is what's happening. 

 

Please explain exactly how you want the calculation to work. 

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

I want to calculate the 5% tax using the "Fill_76" field and the "Full Clean" field and the "Floors only" field and I want the result to show up in "Fill_81"

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

I would like the %5 gst to only calculate for the "fill_76" and the "Full Clean" field and the "Floors only" field. I want the tax total to appear in "fill_81"

Therese Picton
Executive Assistant
[cid:image001.png@01DACED4.EC92C040]
Office: 250-615-6100 Toll Free: 1-800-663-3208 Fax: 250-635-9222
Email: tpicton@rdks.bc.ca Website: http://www.rdks.bc.ca<>
Northwest BC Resource Benefits Alliance: https://www.nwresourcebenefits.ca/
PLEASE NOTE: This message is intended solely for the use of the individual or organization to whom it is addressed and may contain information that is privileged, confidential and prohibited from disclosure under the Freedom of Information and Protection of Privacy Act and other applicable laws. Any other reproduction, distribution or disclosure is strictly prohibited.
Please consider the environment before printing this e-mail.
________________________________

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

The 5% calculation on the sum of the three fields should be:

(a+b+c) * .05

 

 

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

Thank you, I attached the actual file and I have another question.  At the top of the form there are check boxes for youth groups and non profit group.  Is there a way if someone clicked the Yes box in one of these fields that the discount would automatically appear at the bottom of the form in the fields "nonprofit group 15%" or "Youth Group 25%" depending on the option they chose. How would I write this?

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

You need 2 sets of radio buttons:  One for Youth and another for non-profit.  Change the export values of the Yes buttons to .15 and .25 respectively, and the No buttons to zero.  The text fields are shown as $ not percent.  % of which field?  You put a calculation in the text fields that says Value is the product of then select the 2 fields (the radio button set and the field that it is a percentage of).

 

Polite suggestion: You should put seperate questions in separate posts to make it easier for readers to search and find answers.

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

Where do I change the export values of the radio buttons?  Thank you for the suggestion. Going forward I will.

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

It's called Radio button choice in the options tab.

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

This is the result I get. Not sure why the value of product field is not working properly.  Here is the form attached.

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

You must change the fields calculation order so that fill_81 comes after fill_76 in the list.

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

I did that but it is still not working.

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

368.75 should be the discount amount and the total rental less discount is the total rental less the discount.

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 ,
Jul 05, 2024 Jul 05, 2024

Copy link to clipboard

Copied

I think you totally misunderstood my directions on the radio buttons.  You originally had one set of radio buttons for 4 possible answers, now you have 4 separate radio buttons.  You need a Yes/No set for Youth Group and a Yes/No set for Non-Profit.  The export values should be the decimals only, (i.e. .15 and .25), not Choice 1=".25".  Better yet, I wouldn't even use radio buttons.  I would use one check box for Youth Group and another for Non-profit.  The export values will be either .15/.25 when checked, or "Off" when unchecked.

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 ,
Jul 08, 2024 Jul 08, 2024

Copy link to clipboard

Copied

LATEST

Thank you, everything is working great.

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