Skip to main content
Participant
December 8, 2023
Answered

If box checked then (this value) otherwise let me enter custom value

  • December 8, 2023
  • 1 reply
  • 789 views

I have been searching all morning and haven't been able to properly execute anything I have found to help with my problem!

  • On my form, I have two text boxes: "Start Time" and "End Time".
  • I also have a checkbox for "All Day Access".
  • Basically, if you check the box for "All Day Access", I want "Start Time" to autofill to "8:00 AM" and "End Time" to autofill to "5:00 PM".

I was able to get that fine with the calculation scripts:

event.value=this.getField("Or All Day Access").value=="Off"?"":"5:00PM";

(and separately, in the calculation Script for "Start Time" field):

event.value=this.getField("Or All Day Access").value=="Off"?"":"8:00AM";

 

However, when the "All Day Access" box is unchecked, it won't let me enter custom text into the Start and End Time fields. 

 

I know this has got to be an easy solution, I just can't find it!

This topic has been closed for replies.
Correct answer try67

Use this:

if (this.getField("Or All Day Access").value!="Off") event.value = "5:00PM";

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
December 8, 2023

Use this:

if (this.getField("Or All Day Access").value!="Off") event.value = "5:00PM";

Participant
December 8, 2023

Thank you very much!

When I uncheck "All Day Access" it still leaves "8:00 AM"/"5:00 PM" in the text fields, but I am able to edit them now. Is there a way to have those fields cleared/blank (so someone can type in a custom value) if "All Day Access" is not checked?

try67
Community Expert
Community Expert
December 8, 2023

In order to do that you need to move the code to the Mouse Up event of the check-box field, and change it to:

this.getField("Or All Day Access").value = (event.value=="Off") ? "" : "5:00PM";