Taxes check box problem

New Here ,
Apr 11, 2022 Apr 11, 2022

Copy link to clipboard

Copied

I have a form that need a check box to add or not taxes to the right column. So the unit price must be multiplied by the quantity and if the check box is checked, it added taxes to the last column. The problem, is when I check the other check box below, it remove the taxes of the first line. Can somebody help me with this?
 
Here’s my script and a visual of the form to help understand:
 
this.getField("Text Field 21").value=this.getField("Text Field 18").value*this.getField("Text Field 181").value;
var tax_rate = 0.13;
var subtotal = Number(this.getField("Text Field 21").valueAsString);
if (this.getField("AddTax").valueAsString=="Off")
event.value = subtotal;
else event.value = subtotal * (1+tax_rate);
TOPICS
General troubleshooting , JavaScript

Views

93

Likes

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

correct answers 1 Correct answer

Adobe Community Professional , Apr 11, 2022 Apr 11, 2022

Use this for  "Text Field 21" also update other fields with same script just change field names:

var subtotal= Number(this.getField("Text Field 18").value)*Number(this.getField("Text Field 181").value);
var tax_rate = 0.13;
if (this.getField("AddTax").valueAsString=="Off")
event.value = subtotal;
else event.value = subtotal * (1+tax_rate);

And don't forget about field calculation order.

Likes

Translate

Translate
Adobe Community Professional ,
Apr 11, 2022 Apr 11, 2022

Copy link to clipboard

Copied

Are you using any other scripts? Can you share file?

Likes

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 ,
Apr 11, 2022 Apr 11, 2022

Copy link to clipboard

Copied

 

Likes

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
Adobe Community Professional ,
Apr 11, 2022 Apr 11, 2022

Copy link to clipboard

Copied

You need to change field calculation order. Select prepare form tool -> click on 'More' -> then 'Set field calculation order' make sure fields that should calculate first are up on the list and fields that calculate last are down.

 

EDIT: it should look something like this:

Izrezak.PNG

Likes

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 ,
Apr 11, 2022 Apr 11, 2022

Copy link to clipboard

Copied

Hi Nesa,

 
It didn’t help with my problem. Try check and uncheck the second, third or fourth check Box. This changes the first price on the right column.
 
Thanks a lot!

Likes

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
Adobe Community Professional ,
Apr 11, 2022 Apr 11, 2022

Copy link to clipboard

Copied

Use this for  "Text Field 21" also update other fields with same script just change field names:

var subtotal= Number(this.getField("Text Field 18").value)*Number(this.getField("Text Field 181").value);
var tax_rate = 0.13;
if (this.getField("AddTax").valueAsString=="Off")
event.value = subtotal;
else event.value = subtotal * (1+tax_rate);

And don't forget about field calculation order.

Likes

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 ,
Apr 11, 2022 Apr 11, 2022

Copy link to clipboard

Copied

LATEST

Hi Nesa, It work fine!!! 😄 

 
Thanks you so much, have a nice day!
 

Likes

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