if then statement help

New Here ,
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, How to

Views

102

Likes

Report

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

if then statement help

New Here ,
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, How to

Views

103

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 12, 2020 0
14 Replies 14
Adobe Community Professional ,
Aug 12, 2020

Copy link to clipboard

Copied

You must use Javascript code for this.

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 12, 2020 0
New Here ,
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?

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 12, 2020 0
Adobe Community Professional ,
Aug 12, 2020

Copy link to clipboard

Copied

Javascript code looks like this:

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 12, 2020 0
New Here ,
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}

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 12, 2020 0
Most Valuable Participant ,
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

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 12, 2020 0
Enthusiast ,
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%?

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 12, 2020 0
New Here ,
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.

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 12, 2020 0
Participant ,
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;

@+

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 12, 2020 0
New Here ,
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

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 12, 2020 0
Engaged ,
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

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 12, 2020 0
New Here ,
Aug 12, 2020

Copy link to clipboard

Copied

Just tax

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 12, 2020 0
Enthusiast ,
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;

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 12, 2020 0
Participant ,
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"...

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 12, 2020 0
LATEST
New Here ,
Aug 12, 2020

Copy link to clipboard

Copied

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

Likes

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 12, 2020 0