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

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

469

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

Community Expert , 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.

Votes

Translate

Translate
Community Expert ,
Apr 11, 2022 Apr 11, 2022

Copy link to clipboard

Copied

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

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

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
Community Expert ,
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

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 ,
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!

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 ,
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.

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 ,
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!
 

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