Enforcing only one item selected with additional logic

  • johnfaig
    Asked on August 20, 2019 at 9:43 AM

    Please see the referenced form.  The form is a club registration for students and the options on each day are specific to the grade of the student (passed in via URL).

    I need to enforce that only one club can be selected on any day.  Should I add logic to the individual checkboxes OR should I use another type of widget?  I'm happy using another widget, but the options need to be enabled/disabled based on the grade in the URL.

  • AshtonP
    Replied on August 20, 2019 at 11:40 AM

    I have checked your form and the best thing would be to add an individual logic to the check-boxes as per your requirement/conditions. We would be happy to create demo form for you in case you require the same.

    Please feel free to reach us if you have any questions.

  • johnfaig
    Replied on August 20, 2019 at 2:23 PM

    A demo would be great or just show me how to disable a field without explicitly checking every other field on a given day.

  • Victoria_K
    Replied on August 20, 2019 at 3:40 PM

    Good day,

    I think if you will decide applying conditions, there would not be any easy option to check all possible combinations to make sure that everything will work flawlessly.

    May I ask why do you use separate checkboxes and not a single fields with all clubs listed? A single field could be limited to 1 selection via settings. 

    The other way I see, would be to assign calculation values to checkboxes and sum up them in hidden calculation field (I see you have probably started setting this up). Then, a condition can check if calculated total is greater than '1' and block the form somehow (hide Submit button, for example). A warning text, which you already have on form, can be also shown with same condition. Would this work for you?

    How-to-Show-or-Hide-Fields-Base-on-User-s-Answer

  • johnfaig
    Replied on August 20, 2019 at 4:16 PM

    Thanks for the feedback.

    I did some reading and came to the same conclusion that there was no easy way to perform the conditionals.  It might be a nice to have some array functions that could operate on similarly named fields (e.g., checbox_amount1, checbox_amount2, etc.).  It might even be nice to have a field calculation widget that allowed some Javascript coding to do complex conditionals.

    I ended up giving each checkbox a default value of 1 and using a form calculation widget to total all of the checkboxes.  If more than one checkbox is selected I show a bold red text error message and disable the sub,it button.  I can't prevent users from making errors, but I can show them the days where more than one club is selected and disabling the sub,it button.