Skip to main content
Known Participant
September 4, 2025
Question

Calculations and Check boxes

  • September 4, 2025
  • 1 reply
  • 195 views

I have used javascript to crfeate a calculation that works. See below.

event.value = this.getField("End Time Day One").value - this.getField("Start Time Day One").value;
if (isNaN(event.value) || event.value == 0) {
event.value = ("");
}

if (this.getField("Check Box 1").value != "Off") {
event.value = this.getField("Total Hours Day One").value - 1;
}

However, when using this code and changing the fields to represent a different day, when the box is checked in the different day it subtracts from day one also, an d when unchecked and rechecked it continues to subtract. See below.

event.value = this.getField("End Time Day Two").value - this.getField("Start Time Day Two").value;
if (isNaN(event.value) || event.value == 0) {
event.value = ("");
}

if (this.getField("Check Box 2").value != "Off") {
event.value = this.getField("Total Hours Day Two").value - 1;
}

I aslo have the same problem with day 3 and check box 3.

Any help would be appreciated.

Thank you

1 reply

try67
Community Expert
Community Expert
September 4, 2025

Is this the calculation script of "Total Hours Day One" or "Total Hours Day Two"?

brantpro1Author
Known Participant
September 4, 2025

The top one is for Day One and the bottom one is for day two.

try67
Community Expert
Community Expert
September 4, 2025

That's the problem, then. You created circular logic, where the field's own value is used for its calculation.

You need to take a step backwards and think about how this is supposed to work, exactly. What are you trying to calculate here?