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

if then statement help

New Here ,
Aug 12, 2020 Aug 12, 2020

Copy link to clipboard

Copied

Hello all,

I am trying to create an if /then statement on a sales agreement that needs to calculate different amounts of tax based on the amount of the sale. I don't know if I am using the wrong field names or what but I keep getting syntax errors.

We have a 6% sales tax with an additional Education tax of .5% up to $5000. Everything over $5000 is a 6% tax. The name of the cell that has the value of the subtotal of the sale in it is called SubTotal, the "Tool tip" name is "$_Row_1"

Here is my equation description:

I want to calculate the amount of tax to charge based on the amount in the "SubTotal" cell.

If statement: If cell named SubTotal is < $5000

If True:  then SubTotal * 6.5% (.065)

If False (greater than $5000):  then subtract $5000 from the SubTotal amount and multiply it by 6% (.06) and add $325 ($325 is 6.5% of the first $5000)

 

Here is what I put in the calculation field for "Sale Tax":

 

if(SubTotal<5000, SubTotal*.065,
((SubTotal-5000)*.06)+325)

 

What am I doing wrong? Thanks in advance for your help.

TOPICS
Acrobat SDK and JavaScript

Views

1.4K

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 ,
Aug 12, 2020 Aug 12, 2020

Copy link to clipboard

Copied

You must use Javascript code for 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
New Here ,
Aug 12, 2020 Aug 12, 2020

Copy link to clipboard

Copied

Thanks for your reply. I'm used to formulas in Excel.  What would the Javascript code be entered to do the same thing?

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 ,
Aug 12, 2020 Aug 12, 2020

Copy link to clipboard

Copied

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 ,
Aug 12, 2020 Aug 12, 2020

Copy link to clipboard

Copied

I updated the equation to the following that lets me enter it without errors but it does nothing.

 

if (SubTotal<5000) {SubTotal*.065} else
{((SubTotal-5000)*.06)+325}

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 ,
Aug 12, 2020 Aug 12, 2020

Copy link to clipboard

Copied

You're missing a bunch of important stuff... Read this tutorial, too: https://acrobatusers.com/tutorials/how-to-do-not-so-simple-form-calculations

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 ,
Aug 12, 2020 Aug 12, 2020

Copy link to clipboard

Copied

In what field are you try to get result (Same field where value is, or you have another field(example: total price))? and what tax you want if value is exactly $5000 6.5% or 6%?

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 ,
Aug 12, 2020 Aug 12, 2020

Copy link to clipboard

Copied

I have the formula in a field named SalesTax

If the amount was exactly $5000 it would be taxed at the 6% rate because the extra .5% education tax goes "up to $5000".

Thanks.

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 ,
Aug 12, 2020 Aug 12, 2020

Copy link to clipboard

Copied

In calculation script of the SalesTax field:

if (SubTotal<5000) event.target.value=SubTotal*=.065;

else event.target.value=((SubTotal-5000)*.06)+325;

@+

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 ,
Aug 12, 2020 Aug 12, 2020

Copy link to clipboard

Copied

Hmmm, that didn't work. I tried it with the @+ on the end and it gave me a syntax error

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
Enthusiast ,
Aug 12, 2020 Aug 12, 2020

Copy link to clipboard

Copied

You want SalesTax to show price with aded tax or just tax?

example: $6000= $6360 or just $360

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 ,
Aug 12, 2020 Aug 12, 2020

Copy link to clipboard

Copied

Just tax

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 ,
Aug 12, 2020 Aug 12, 2020

Copy link to clipboard

Copied

Try this as custom calculation script of SalesTax field:

 

var SubTotal = Number(this.getField("SalesTax").value);
if (SubTotal < 5000){
event.value = SubTotal*.065;
}else event.value = SubTotal*.06;

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 ,
Aug 12, 2020 Aug 12, 2020

Copy link to clipboard

Copied

LATEST

I played around with it for a while and got it to work:

 

var SubTotal = Number(this.getField("SubTotal").value);
if (SubTotal < 5000) {event.value = SubTotal*.065;} else {event.value = ((SubTotal-5000)*.06)+325;}

 

Thank you so much for your help!

jamesbo

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 ,
Aug 12, 2020 Aug 12, 2020

Copy link to clipboard

Copied

Please, don't type "@+"!!!

for French people's, @+ means "see you soon" or "talk to you soon"...

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