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

Create a check box on a price list that if checked gives $0 total

New Here ,
Jul 21, 2016 Jul 21, 2016

I have a plumbing supplies price list which consists of 5 pages of items, each with a check box. These items total into the subtotal field if checked. Now, the client wants a variable that if the purchase is for a model home, there is no charge. I already have a "model home" check box, so I need to find out how to set this up so that if it is checked, the "sub total" field is "0". Is there an easy way to do this?

TOPICS
Acrobat SDK and JavaScript
424
Translate
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 , Jul 21, 2016 Jul 21, 2016

You can use this code as the custom calculation script for sub-total:

if (this.getField("model home").value!="Off") event.value = 0;

else event.value = Number(this.getField("page 1 total").value) + Number(this.getField("page 2 total").value) + Number(this.getField("page 3 total").value) + Number(this.getField("page 4 total").value) + Number(this.getField("page 5 total").value);

Translate
Community Expert ,
Jul 21, 2016 Jul 21, 2016

Can you post the current code you're using for the calculation of the sub total field?

Basically, adding this line to the end of it should do the trick:

if (this.getField("model home").value!="Off") event.value = 0;

Translate
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 ,
Jul 21, 2016 Jul 21, 2016

Thanks so much for responding so quickly!

I currently am using the "Value is the sum of the following fields" and then I selected my fields page 1 total, page 2 total, page 3 total, page 4 total, page 5 total

Is there a way I can use a custom calculation to do the same thing? I am brand new to Javascript.

Translate
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 ,
Jul 21, 2016 Jul 21, 2016

You can use this code as the custom calculation script for sub-total:

if (this.getField("model home").value!="Off") event.value = 0;

else event.value = Number(this.getField("page 1 total").value) + Number(this.getField("page 2 total").value) + Number(this.getField("page 3 total").value) + Number(this.getField("page 4 total").value) + Number(this.getField("page 5 total").value);

Translate
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 ,
Jul 21, 2016 Jul 21, 2016
LATEST

That worked! Thank you so much!

Translate
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