Copy link to clipboard
Copied
I'm back, again with another stumper. I also get my questions answered and am grateful for the help.
I have a field ("Hours") with a simple sum calculation, however, I am hoping that I can find a way that if a check box (Check Box1) is ticked, then the "Hours" field will display 0. Likewise in reverse. If that same check box is unticked, then the "Hours" field will revert to the original calcualtion. Is there a way to do this?
Thank you!
If those are field names use this:
if(this.getField("Check Box2.0").value == "Off"){
event.value = Number(this.getField("Estimated S3 Worker Labor HoursRow1").valueAsString)+Number(this.getField("Estimated NonS3 Worker Labor HoursRow1").valueAsString);}
else
event.value = 0;
Copy link to clipboard
Copied
Yes,
if(this.getField("Check Box1").value == "Off")
{// Checkbox is unchecked
.. Original calculation ...
}
else// Checkbox is checked.
event.value = 0;
Copy link to clipboard
Copied
Thank you for your reply. This is not working. I copied and pasted, insterted the original calucation where indicated. I am getting a Syntax Error: missing; before statement 4: and line 5.
Copy link to clipboard
Copied
EDIT: from what I can see, you are missing one '=' sign here: if(this.getField("Check Box1").value == "Off")
Copy link to clipboard
Copied
Good catch, thanks Nesa, that comparison operator detail is a persistent human error. I fixed it in the post.
However, that doesn't explain the syntax error, which is in the posters original code.
Please post your entire calculation script.
Copy link to clipboard
Copied
Thank you, Nesa.
Would you mind please to post the entire script with your revision? Just to double check, I am using this as a calculation script not a mouse up action javascript, right?
Copy link to clipboard
Copied
The script above is now fixed by Thom, but if you still have an issue, please post your script, so I can take a look.
Copy link to clipboard
Copied
Thank you.
if(this.getField("Check Box2.0").value == "Off")
{// Checkbox is unchecked
=Estimated S3 Worker Labor HoursRow1 + Estimated NonS3 Worker Labor HoursRow1
}
else// Checkbox is checked.
event.value = 0;
Copy link to clipboard
Copied
If those are field names use this:
if(this.getField("Check Box2.0").value == "Off"){
event.value = Number(this.getField("Estimated S3 Worker Labor HoursRow1").valueAsString)+Number(this.getField("Estimated NonS3 Worker Labor HoursRow1").valueAsString);}
else
event.value = 0;
Copy link to clipboard
Copied
Beautiful! Thank you both, Nesa and Thom!