## calculation help - (Q1*\$1)-(DISC1/100) and SUB is empty IF 0

Community Beginner ,
Nov 30, 2018

Copied

Attached is a link to the photos of my invoice form. I have the following columns:

Q=QTY.

\$=\$

DISC1=DISCT.

SUB=SUBTOTAL

I would like the subtotal to accurately calculate from the corresponding row values. Essentially the calculation of (Q1*\$1)-(DISC1/100) so that the discount column presents as 35% instead of .35 when I present it to clients.

Then, how do I code SUBTOTAL as empty when the corresponding rows are empty.

Community Beginner
| Community Beginner

thank you! those articles in conjuction were perfect for my puzzle. I ended up with this:

event.value = (this.getField('Q1').value && this.getField('\$1').value && this.getField('DISC1').value) ? ((this.getField('Q1').value*this.getField('\$1').value)-(this.getField('DISC1').value/100)) : "";

TOPICS
Acrobat SDK and JavaScript, Macintosh

Views

146

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

## calculation help - (Q1*\$1)-(DISC1/100) and SUB is empty IF 0

Community Beginner ,
Nov 30, 2018

Copied

Attached is a link to the photos of my invoice form. I have the following columns:

Q=QTY.

\$=\$

DISC1=DISCT.

SUB=SUBTOTAL

I would like the subtotal to accurately calculate from the corresponding row values. Essentially the calculation of (Q1*\$1)-(DISC1/100) so that the discount column presents as 35% instead of .35 when I present it to clients.

Then, how do I code SUBTOTAL as empty when the corresponding rows are empty.

Community Beginner
| Community Beginner

thank you! those articles in conjuction were perfect for my puzzle. I ended up with this:

event.value = (this.getField('Q1').value && this.getField('\$1').value && this.getField('DISC1').value) ? ((this.getField('Q1').value*this.getField('\$1').value)-(this.getField('DISC1').value/100)) : "";

TOPICS
Acrobat SDK and JavaScript, Macintosh

Views

147

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
Nov 30, 2018 0
9 Replies 9
Community Beginner ,
Nov 30, 2018

Copied

is the link to the photos

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
Nov 30, 2018 0
Most Valuable Participant ,
Nov 30, 2018

Copied

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
Nov 30, 2018 1
Community Beginner ,
Nov 30, 2018

Copied

I found that article on my search before posting, but I need a custom calculation script in order to get the SUB=empty if Q,\$,and DISC are empty

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
Nov 30, 2018 0
Most Valuable Participant ,
Nov 30, 2018

Copied

You need a simple if-condition. See: https://acrobatusers.com/tutorials/conditional-execution

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
Nov 30, 2018 1
Community Beginner ,
Nov 30, 2018

Copied

thank you! those articles in conjuction were perfect for my puzzle. I ended up with this:

event.value = (this.getField('Q1').value && this.getField('\$1').value && this.getField('DISC1').value) ? ((this.getField('Q1').value*this.getField('\$1').value)-(this.getField('DISC1').value/100)) : "";

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
Nov 30, 2018 0
LATEST
Most Valuable Participant ,
Nov 30, 2018

Copied

Well done!

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
Nov 30, 2018 2
Most Valuable Participant ,
Nov 30, 2018

Copied

It is best not to ask "how to code" because it can be seen as just asking us to write your code for you. Most of us are more interested in giving you what you need to learn how to write your own.

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
Nov 30, 2018 0
Community Beginner ,
Nov 30, 2018

Copied

I did take the articles that try67 sent to me, as per my request on "how to code" and I came up with a code that works perfectly

event.value = (this.getField('Q1').value && this.getField('\$1').value && this.getField('DISC1').value) ? ((this.getField('Q1').value*this.getField('\$1').value)-(this.getField('DISC1').value/100)) : "";

you've misinterpreted my intentions. I love finding the "why" behind the code, not just the "how"

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
Nov 30, 2018 0
Community Beginner ,
Nov 30, 2018

Copied

not just the "what"**

excuse the typo! and thank you again for suggestions!

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
Nov 30, 2018 0