Can Fields Be Shown or Hidden Based on a Default or Selected Date?

  • hangingout
    Asked on September 23, 2015 at 8:34 AM

    Meaning if I have a drop down box, that I want to include just the next 3 months, is it possible to do that.

    So if it is september now, the box would drop down, OCT, NOV, DEC. But next month the drop down would be NOV, DEC, JAN

  • abajan Jotform Support
    Replied on September 23, 2015 at 1:44 PM

    Yes, this is possible. Please have a look at this form which you would recognize as being based on yours. If you were to clone it, you would notice that numbers are appended to the labels of the month fields. This was just to avoid any confusion while creating the conditions:

    Can Fields Be Shown or Hidden Based on a Default or Selected Date? Image 1 Screenshot 70

    However, once conditions have been tested and have been found to be functioning correctly, those numbers can be removed.

    To achieve the show/hide dropdown functionality what I did was:

    1. Add 12 month dropdowns and edit their options accordingly

    2. Insert a Form Calculation widget (See our widget guide)

    3. Add the second date field to its work area and then click 0-9 to change it to a-z and the button from orange to grey:

    Can Fields Be Shown or Hidden Based on a Default or Selected Date? Image 2 Screenshot 81

    Can Fields Be Shown or Hidden Based on a Default or Selected Date? Image 3 Screenshot 92


    4. Create 12 conditions attached to that widget to capture the first two (2) digits (the month) of the the date. The Form Calculation widget was necessary because there's no Starts With condition available for date fields:

    Can Fields Be Shown or Hidden Based on a Default or Selected Date? Image 4 Screenshot 103


    5. Hide the calculation field:

    Can Fields Be Shown or Hidden Based on a Default or Selected Date? Image 5 Screenshot 114


    6. Set the form to clear fields on their being hidden:

    Can Fields Be Shown or Hidden Based on a Default or Selected Date? Image 6 Screenshot 125

    This is necessary so that if a selection is made in a month field and then that field becomes hidden if a different date is selected in the date field, the selection is cleared.

    That's basically all I did but if you would like clarification on anything, please inform us.


    Thanks

  • hangingout
    Replied on September 24, 2015 at 12:47 AM
    Thanks, that is really helpful.
    ...
  • Charlie
    Replied on September 24, 2015 at 9:39 AM

    In behalf of my colleague, you are welcome. Glad to hear that the suggestion helped.

    Should you need any assistance again, feel free to open a new thread here in the forum.

    Thank you.