Skip to main content
LHGgraphics
Participating Frequently
July 21, 2016
Answered

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

  • July 21, 2016
  • 1 reply
  • 460 views

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?

This topic has been closed for replies.
Correct answer try67

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);

1 reply

try67
Community Expert
Community Expert
July 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;

LHGgraphics
Participating Frequently
July 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.

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
July 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);