Increment a variable or counter

  • HelpingMamas
    Asked on September 23, 2022 at 12:59 PM

    In my form I have a number of drop downs with the same text options. I want to be able to count the number of times a certain selection is made in all of the drop downs. I'm at a loss as to how to accomplish this.

    In my form, the are 16 "Month" fields where the user can select diaper size. I need to know the total number of months a size is selected.

  • KrisLei Jotform Support
    Replied on September 23, 2022 at 2:52 PM

    Hi HelpingMamas,

    To my understanding, you would like to count how many times an option is selected on all dropdowns, correct? It seems this is possible by assigning values to each option, then using the Calculate/Insert condition to calculate the number of times an option is selected.

    Kindly give me more time to explain the steps to implement this on the form. I will get back to you shortly.

  • Peggy Amend
    Replied on September 23, 2022 at 3:02 PM

    Appreciate your help.

  • KrisLei Jotform Support
    Replied on September 25, 2022 at 5:38 AM

    Hello Peggy,

    My sincerest apologies for the delay.

    It seems that we need additional steps to meet your requirements. So I created a demo form that consists of 4 dropdowns, 1 Input table and 4 Form Calculation widgets. Please refer to the steps below:

    1) First, add an Input Table element with the Textbox as the Input Type field. Then label the rows with the 'Months' (labels of the dropdown fields), then the labels for the column will be the sizes:

    1664096507 633018fb0d9b0  Screenshot 10

    This way, we can collate the gathered information from each dropdown.

    2) Create Calculate Conditions to assign the value of '1' on the table based on the user's response. Similar to the conditions below:

    1664097206 63301bb6b62ac  Screenshot 21

    You would need to create conditions for each month and each option. In my demo form, I only included 4 options for the sizes, so I created 4 conditions per month:

    1664096948 63301ab4552dc  Screenshot 32

    You can refer to this guide on inserting values using conditions on another field: How to Insert Text or Calculation into a Field Using Conditional Logic.

    3) Add Form Calculation widgets to calculate the total of each size selected based on the Input Table. So each widget will represent each option or size. So I added 4 widgets, as I only added 4 options for the sizes:

    1664097570 63301d2238473  Screenshot 43

    Then on each widget, you can add or calculate the values per size (column) based on the Input Table. Please refer to the screencast below. (Please note that I labelled the Input Table as 'Count'):

    1664097946 63301e9a57cc5 form Screenshot 54

    Please feel free to check the results here on my demo form: https://form.jotform.com/222654584576063

    I also highly suggest doing these steps in 4 parts or every 4 months (as shown on your form) instead of the whole 16 months (or at once) to prevent confusion with the conditions. Then at the end of the form, you can add another set of Form Calculation widgets for each size to calculate the total values from the previous widgets.

    I hope this helps, and please do let us know if it doesn't meet your requirements.


  • HelpingMamas
    Replied on September 26, 2022 at 11:25 AM
    Hi,
    Thanks for this. The final gif is a broken link, would you be able to
    resend?
    Many thanks,
    Pegi
    ...