Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.
SOLVED

Autofill dates

Avatar

Level 1

I am creating a form where I would like a section to autofill with dates.

I would like for the people who will be using this form to put a date into

one box and the next seven date automatically appear in the next seven boxes.

Example: (information is entered into box 1 and boxes 2-8 autofill)

Box 1: 09/13/10

Box 2: 09/14/10

Box 3: 09/15/10

Box 4: 09/16/10

Box 5: 09/17/10

Box 6: 09/18/10

Box 7: 09/19/10

Box 8: 09/20/10

Box 9: 09/21/10

I have tried using FormCalc to acheive this but I have not yet succeeded. Could someone help me? Any ideas are appriciated. Thanks!

1 Accepted Solution

Avatar

Correct answer by
Former Community Member

// form1.page1.date1::exit - (FormCalc, client)


var dayNum = Date2Num($.formattedValue,"MM/DD/YYYY")

date2.rawValue = Num2Date(dayNum+1,"MM/DD/YYYY")

date3.rawValue = Num2Date(dayNum+2,"MM/DD/YYYY")

date4.rawValue = Num2Date(dayNum+3,"MM/DD/YYYY")

date5.rawValue = Num2Date(dayNum+4,"MM/DD/YYYY")

date6.rawValue = Num2Date(dayNum+5,"MM/DD/YYYY")

date7.rawValue = Num2Date(dayNum+6,"MM/DD/YYYY")

date8.rawValue = Num2Date(dayNum+7,"MM/DD/YYYY")

where all date fields have a display pattern MM/DD/YYYY

Steve

View solution in original post

3 Replies

Avatar

Correct answer by
Former Community Member

// form1.page1.date1::exit - (FormCalc, client)


var dayNum = Date2Num($.formattedValue,"MM/DD/YYYY")

date2.rawValue = Num2Date(dayNum+1,"MM/DD/YYYY")

date3.rawValue = Num2Date(dayNum+2,"MM/DD/YYYY")

date4.rawValue = Num2Date(dayNum+3,"MM/DD/YYYY")

date5.rawValue = Num2Date(dayNum+4,"MM/DD/YYYY")

date6.rawValue = Num2Date(dayNum+5,"MM/DD/YYYY")

date7.rawValue = Num2Date(dayNum+6,"MM/DD/YYYY")

date8.rawValue = Num2Date(dayNum+7,"MM/DD/YYYY")

where all date fields have a display pattern MM/DD/YYYY

Steve

Avatar

Level 1

This is great - how can I see the code so I  can add it to my form please?  (Jeffokun2@Gmail.com)

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----