Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

date field auto fill text boxes

Avatar

Level 1

I have a form I am designing. Users will input a week ending date (05/09/2020), and I want this to then populate text boxes with the dates for sunday through saturday, i.e. the textbox named Sun would fill with the number 3 (for May 3), textbox named Mon would fill with the number 4 (for May 4) and so on for each day of the week.  Is there a format to accomplish this? I assume I could use the date 05/09/2020, and use a script to subtract the number of days I needed to get the right date.  

 

 

Thanks in advance

 

 

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi, 

 

with FormCalc you can easily calculate dates.

In the exit event of you date field, add a script like this

 

if ($.isNull eq 0) then
	var nDate = Date2Num($.formattedValue, "MM/DD/YYYY")
	Mon = Num2Date(nDate - 6, "EEE D")
	Tue = Num2Date(nDate - 5, "EEE D")
	Wed = Num2Date(nDate - 4, "EEE D")
        ; and so on ...
endif

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

Hi, 

 

with FormCalc you can easily calculate dates.

In the exit event of you date field, add a script like this

 

if ($.isNull eq 0) then
	var nDate = Date2Num($.formattedValue, "MM/DD/YYYY")
	Mon = Num2Date(nDate - 6, "EEE D")
	Tue = Num2Date(nDate - 5, "EEE D")
	Wed = Num2Date(nDate - 4, "EEE D")
        ; and so on ...
endif