Skip to main content
Known Participant
Sep 4, 2025 2:29 PM UTC
Question

Calculations and Check boxes

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

5 replies

try67
Community Expert
Community Expert
Sep 4, 2025 7:14 PM UTC

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

Translate
brantpro1Author
Known Participant
Sep 4, 2025 7:17 PM UTC

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

Translate
try67
Community Expert
Community Expert
Sep 4, 2025 7:23 PM UTC

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?

Translate