-
1. Re: Hi! Need to have a checkbox subtract a text field value from the grand total of a calculation.
try67 Apr 13, 2017 3:30 PM (in response to nikkiw49131245)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?
-
2. Re: Hi! Need to have a checkbox subtract a text field value from the grand total of a calculation.
Joel_Geraci Apr 13, 2017 3:31 PM (in response to nikkiw49131245)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".
-
3. Re: Hi! Need to have a checkbox subtract a text field value from the grand total of a calculation.
nikkiw49131245 Apr 13, 2017 3:35 PM (in response to try67)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"
-
5. Re: Hi! Need to have a checkbox subtract a text field value from the grand total of a calculation.
try67 Apr 14, 2017 1:58 AM (in response to nikkiw49131245)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[i]); if (f==null) { console.println("Error! Can't find: " + fields[i]); continue; } total+=Number(f.value); } if (this.getField("GST Exempt").value=="Off") { total+=Number(this.getField("GST 5").value); } event.value = total;
-
6. Re: Hi! Need to have a checkbox subtract a text field value from the grand total of a calculation.
nikkiw49131245 Apr 19, 2017 7:46 AM (in response to try67)Sorry for the delayed reply..today was the first chance I was able to test the above script. It worked brilliantly!!!!!! Thank you so much - i really appreciate it!!!!!!!!!!!!!!!!!!!!!!
-
7. Re: Hi! Need to have a checkbox subtract a text field value from the grand total of a calculation.
gkaiseril Apr 19, 2017 10:20 AM (in response to nikkiw49131245)See How to do (not so simple) form calculations by Thom Parker.
-
8. Re: Hi! Need to have a checkbox subtract a text field value from the grand total of a calculation.
nikkiw49131245 Apr 26, 2017 8:41 AM (in response to try67)Me again. Thanks so much for your assistance previously! Now i have a hit a little snag....
In my previous post i mentioned that these were the fields 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"
I realized i forgot to include one field which originally was titled "x. 8566" which now i would like to change to "KM Total". This field has its own simplified field notation of TransportationFee*.8566
Using the script you provided above, i have tried to manually enter "KM Total" in between "Additional Service" and "Locating" but i can't get it to apply to the calculation and include it. Currently, it's showing all the appropriate fees except for adding in the KM total....what am i doing wrong?
-
9. Re: Hi! Need to have a checkbox subtract a text field value from the grand total of a calculation.
try67 Apr 26, 2017 8:47 AM (in response to nikkiw49131245)Hard to say... It will help if you posted your code, as well as any error messages that appear in the JS Console.
-
10. Re: Hi! Need to have a checkbox subtract a text field value from the grand total of a calculation.
nikkiw49131245 Apr 26, 2017 9:27 AM (in response to try67)Here is the script i have now entered: "KM Total is now added in"
var fields =["AdditionalService","KM Total", "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[i]);
if (f==null) {
console.println("Error! Can't find: " + fields[i]);
continue;
}
total+=Number(f.value);
}
if (this.getField("GST Exempt").value=="Off") {
total+=Number(this.getField("GST 5").value);
}
event.value = total;
This is what i'm getting in the JS Console
TypeError: f is null
1051:byteCodeTool
-
11. Re: Hi! Need to have a checkbox subtract a text field value from the grand total of a calculation.
try67 Apr 26, 2017 9:46 AM (in response to nikkiw49131245)It looks like this error is coming from some other script...