List Date Options Based On Proximity To Current Date

Hey Blazers!

This one is racking my brain pretty hard. I know how to do the following in Excel, but am struggling to code it in a Snippet. Here's the scoop:

I have a list of class start dates. I want the Snippet user to only be able to view & select the next 2 class start dates in the second list past whatever class start date is selected in the first list. Check out my sample Snippet below for details. In this sample, if I select 1/3 from the first list, then I want the ONLY options in the second list to be 1/31 and 2/28. Similarly, if I select 5/2 from the first list, then I want the ONLY selectable options in the second list to be 5/31 and 7/27.

{note}
What is the students current start date? {formmenu: 1/3; 1/31; 2/28; 4/4; 5/2; 5/31; 7/27; 8/1; 8/29; 9/26; 10/24; 11/21; name=CurrentStartDate}

What start date would the student like to Bump to? {formmenu: 1/3; 1/31; 2/28; 4/4; 5/2; 5/31; 7/27; 8/1; 8/29; 9/26; 10/24; 11/21; name=NewStartDate}

What is the Program Code? {formtext: name=ProgramCode; default=}

Why does the student want to Bump? {formparagraph: name=Reason; rows=1}

{endnote: trim=no}
{=CurrentStartDate; trim=no} ERTA to Bump
The following student would like to Bump to {=NewStartDate} {=upper(programcode)}

  1. Educational Reason Code:
  2. Detailed reason given by student: {=Reason}

Any ideas on how to accomplish this?

Thank you in advance!
-Brad :fire:

Something like the following should work. It makes the menu options in the second menu a function of the first menu selection:

{dates=["01-03", "01-31", "02-28", "04-04", "05-02"]}

Start date: {formmenu: values={=dates}; name=start}

End date: {formmenu: values={=slice(dates, location(dates, start) + 1, location(dates, start) + 2)}; name=end_date; default=-}

Hopes this helps!

4 Likes

Amazingly simple and elegant! Thank you!!!