• Global community
• Language:
• Deutsch
• English
• EspaÃ±ol
• FranÃ§ais
• PortuguÃªs
• æ—¥æœ¬èªžã‚³ãƒŸãƒ¥ãƒ‹ãƒ†ã‚£
Dedicated community for Japanese speakers
• í•œêµ­ ì»¤ë®¤ë‹ˆí‹°
Dedicated community for Korean speakers
Exit
• Javascript function doing reverse of what I want i...

# Javascript function doing reverse of what I want it to do

Community Beginner ,
Jan 23, 2019 Jan 23, 2019

Copied

I have a work order form I've built and at the end of the form is a checkbox to check if the sale is sales tax exempt.

The fields used are as follows (in the order they appear in the document/tab sequence):

• Pre_Tax_Subtotal (the field for getting the subtotal before tax is calculated)
• SalesTax (the field that calculates the sales tax; custom calculation provided, below )
• GrandTotal (the field for getting the total; basically the sum of Pre_Tax_Subtotal and SalesTax)
• SalesTaxExempt (a checkbox field that returns '1' if checked)

Pre_Tax_Subtotal just takes the sum of line items, which works as expected (using the simple calculations provided by Acrobat).

SalesTax uses the following formula:

if(this.getField('SalesTaxExempt').isBoxChecked(0) == '1'){

event.value = 0;

} else {

var taxRate = .0825;

var subTot = this.getField('Pre_Tax_Subtotal').value;

var stc = subTot * taxRate;

event.value = stc;

}

SalesTax reflects as '0' in the box when the box is checked (as I would expect it) but the GrandTotal reflects a total amount with sales tax included when it should be consistent with the Pre_Tax_Subtotal field. Unchecking SalesTaxExempt puts the calculated sales tax back in, but then the GrandTotal field updates to reflect the Pre_Tax_Subtotal field.

I'm kind of a newbie when it comes to Javascript and I know my variable names/field names don't follow best practices, but surely this isn't why this form is doing this?

Any help is greatly appreciated. All of the form fields except for the SalesTax field use the basic arithmetic functions out of the box. SalesTax is the only custom calculation I've incorporated.

Here is a screencast of the behavior.

TOPICS
Acrobat SDK and JavaScript

Views

337

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 Beginner , Jan 23, 2019 Jan 23, 2019

Okay, my field calculation order was out of sequence with SalesTax falling after the GrandTotal field. After reordering SalesTax BEFORE GrandTotal, the issue has gone away and the form now works as it should. I am marking this as resolved.

Community Beginner ,
Jan 23, 2019 Jan 23, 2019

Copied

LATEST

Okay, my field calculation order was out of sequence with SalesTax falling after the GrandTotal field. After reordering SalesTax BEFORE GrandTotal, the issue has gone away and the form now works as it should. I am marking this as resolved.