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

Script for calculating sales tax on only certain fields

New Here ,
Jul 05, 2024 Jul 05, 2024

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
2.4K
Translate
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

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

(a+b+c) * .05

 

 

View solution in original post

Translate
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

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

Translate
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

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

Translate
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

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"

Translate
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
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.
________________________________
Translate
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

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

(a+b+c) * .05

 

 

Translate
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

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?

Translate
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

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.

Translate
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

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

Translate
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

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

Translate
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

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

Translate
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

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

Translate
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

I did that but it is still not working.

Translate
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

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

Translate
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

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.

Translate
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
LATEST

Thank you, everything is working great.

Translate
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