Skip to main content
April 13, 2017
Question

Hi! Need to have a checkbox subtract a text field value from the grand total of a calculation.

  • April 13, 2017
  • 2 replies
  • 1151 views

When a checkbox is activated "GST Exempt", I would like the GST text field value subtracted from the Total of a sum of fees added together.

Is this possible? I'm assuming the calculation would have to be be applied to the "Total" text field? Thanks!

This topic has been closed for replies.

2 replies

Joel Geraci
Community Expert
Community Expert
April 13, 2017

It's possible but there isn't enough information here to give you the exact code but you'll want the calculation to check if the value of the checkbox is "Off" to decide to subtract the GST value or not. The checked value of the checkbox can be anything but the unchecked value will always be "Off".

try67
Community Expert
Community Expert
April 13, 2017

Yes, it is. Are you currently using a script to calculate the total value? If so, what is your code? If not, then how are you doing it?

April 13, 2017

I have a total box at the bottom of the fees which has this calculation: value is the sum of "AdditionalService, GST 5, Locating, Optional Fee 1, Optional Fee 2, Phone Calls, Photocopies, Postage, Receiving, ServiceExecution"

try67
Community Expert
Community Expert
April 14, 2017

Use this code as the custom calculation script of your total field:

var fields =["AdditionalService", "Locating", "Optional Fee 1", "Optional Fee 2", "Phone Calls", "Photocopies", "Postage", "Receiving", "ServiceExecution"];

var total = 0;

for (var i in fields) {

    var f = this.getField(fields);

    if (f==null) {

        console.println("Error! Can't find: " + fields);

        continue;

    }

    total+=Number(f.value);

}

if (this.getField("GST Exempt").value=="Off") {

    total+=Number(this.getField("GST 5").value);

}

event.value = total;