Copy link to clipboard
Copied
Thanks in advance for reading.
I need some scripting.
I have a Total Field and fields for Mon 1, Tue 1, Wed 1, Thur 1, Fri 1, Sat 1 and Sun 1.
The user will either:
1. Enter their scheduled hours where applicable across Mon 1 through Sun 1, with a possible range of 0-12 per day. In this instance, I need Mon 1-Sun 1 to each verify the range. But the default value of each field must remain "Mon" , "Tue" , "Wed", "Thu" , "Fri", "Sat" and "Sun", respectively, because I use On Focus and On Blur scripts (see below) to instruct the user. Additionally, if the user enters numbers (above 0) into any of the Mon 1-Sun 1 fields, I need Total Field to calculate the total and become uneditable.
2. The user can instead not fill in their schedule and instead only fill in their total hours in Total Field. The range for Total Field must be 1-35, where the default value is "Total".
I'm using these scripts on the fields to instruct the users:
//On Focus//
if (event.target.value==event.target.defaultValue) { event.target.value = ""; event.target.textColor = color.black; }
//On Blur//
if (event.target.value=="") { event.target.value = event.target.defaultValue; event.target.textColor = color.ltGray; }
Your help is much appreciated! (Also any best-practice suggestions are gratefully accepted.)
Copy link to clipboard
Copied
Hi,
I am sorry but I am trying to make sense of your request.
Taking field Mon-1,
default value = "Mon"
this will change to a number between 0 -12 if the user enters anything
if the user deletes this value it will revert back to "Mon"
(and this is to happen for each of the day fields)
is that correct?
is the total field supposed to add all the fields that are not 0 or "Mon" and then populate a field that cannot be changed? by the user
unless the user doesn't want to enter any values into the day fields, and just enter their total in the total field?
is that correct?
Copy link to clipboard
Copied
Yes correct, Barlae. Thanks for your response.
I would clarify that: if user enters values into any of the day fields, the Total Field should display the total of all days (as you say, of all fields not 0 or "Mon") and be uneditable. However, if the user removes the values from all days, the total should become editable again. Also for clarity: each field has a On Blur and On Focus script that displays the default value in ltGray when the field is left blank, i.e. "Mon", "Tue", or "Total". I believe that script will function independently of the script I request from you, but I mention it as an FYI.
I will myself add a button that displays or hides the days of the week fields, which will also 'clear' these fields upon being hidden and restore the default as "Mon" etc. In this case, the total field should also return to Total and be editable. Again, I assume this functionality does not affect my request above. But I do not know what I do not know.
Thanks for your time on this.
Copy link to clipboard
Copied
Is it possible?