Copy link to clipboard
Copied
alright so here is my code, i know it looks crude but its the best ive gotten so far:
if(this.getField("B1").isBoxChecked(0) && this.getField("L1").isBoxChecked(0) && this.getField("D1").isBoxChecked(0))
this.getField("D1T").value = this.getField("Breakfast").value + this.getField("Lunch").value + this.getField("Dinner").value
else if(this.getField("B1").isBoxChecked(0) && this.getField("L1").isBoxChecked(0) || this.getField("L1").isBoxChecked(0) && this.getField("B1").isBoxChecked(0))
this.getField("D1T").value = this.getField("Breakfast").value + this.getField("Lunch").value
else if(this.getField("B1").isBoxChecked(0) && this.getField("D1").isBoxChecked(0))
this.getField("D1T").value = this.getField("Breakfast").value + this.getField("Dinner").value
else if(this.getField("L1").isBoxChecked(0) && this.getField("D1").isBoxChecked(0))
this.getField("D1T").value = this.getField("Lunch").value + this.getField("Dinner").value
else
this.getField("D1T").value = 0
Ok so the issue is when the checkboxes are checked the value of each repsect percentage is calculated and totaled into the respective field. However, when you uncheck a box the value does not update ( supose B1 + D1 + L1 are checked, when B1 is unchecked the total is not updated with the value of D1+L1 instead it just gives me back the default of the total value which is set to 0.) i tried using OR (||) but it just breaks my code making it not calculate at all now
Copy link to clipboard
Copied
Also whenever i box is checked this pops up in the console: TypeError: f is null
1282:byteCodeTool
Copy link to clipboard
Copied
- Where did you place the code?
- The error message suggests you used an incorrect field name somewhere in your calculations, most likely not in a script, but when using the built-in calculation options, or the Simple Field Notation.