Count the number of selections made

  • mgcaledonian13
    Asked on June 13, 2016 at 9:51 AM

    I want to warn users that they have selected more colours / sizes than they asked for in quantity.

    I have a quantity order field and a dropdown selection that I want to check ie if they ask for two items and select three different colors. If this happens I want to warn that this is the case. 

    Jotform Thread 859368 Screenshot
  • Charlie
    Replied on June 13, 2016 at 11:30 AM

    If you want to match the number of quantity to the number of items selected in your check box, then that should be possible by using conditional logic.

    Here's a sample form I made based from your form: https://form.jotform.com/61644834385968 

    1. First, I'll add a "Text" field. This will serve as the warning message when the quantity and the number of check box items are not equal.

    Count the number of selections made Image 1 Screenshot 50

    2. Now we will add the "Form Calculation" widget, this will be used to count the number of check box items selected. You can see I named it "Count selected items in check box".

    Count the number of selections made Image 2 Screenshot 61

    3. Here's how the widget is setup.

    count( check box field)

    The count() function simply counts the number of selected items in a check box. You can learn more about the math functions here: https://www.jotform.com/help/267-Form-Calculation-Math-Function-Reference 

    Count the number of selections made Image 3 Screenshot 72

     

    4. Now we will compare the "Quantity" field and the "Form Calculation" widget using conditional logic. If they are not the same, then we will SHOW the "Text" field with a warning message.

    Count the number of selections made Image 4 Screenshot 83

     

    Let us know if that works.

  • mgcaledonian13
    Replied on June 13, 2016 at 3:26 PM

    Thanks I was on that line, and I will try it latter.

    As always superb service, you guys never cease to amaze me with the speed that you respond to a question. You must be the world record holders.