Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

How to add options to a cell in grid question?

Hi all,

Please see the following format of a grid question.

Rows: different time ranges (8:00-9:00 am, 9:00-10:00 am... etc)
Columns: Location (drop down menu),  who ate the fruit (open-end), and Fruit that were eaten (check all that apply).

Location (drop down menu) - options: home, office, etc.
Fruit (check all that apply) - options: apple, orange, grape, etc.

I want to know for each time range, where & who & the fruit that were eaten. I know the first thing is changing direction in grid question to column direction. I also know how to do the drop down and open-end.

However, I could not figure out how to do the 'check all that apply' for Fruit. I am not sure whether I should put customized code to the footer of grid question  or I should use free-format question? Could anyone please share some code on how to do the 'check all that apply' for fruit? Thank you all!
asked Dec 5, 2017 by Yolanda-Wong (215 points)
If you are going to use a grid question, you will need to include multiple fruit columns.  An apple column, an orange column, a grape column, etc.  This is the only way to have one checkbox for each fruit.

If this is not how you envision the checkboxes laid out, you will either need custom JavaScript in the grid question or need to use a free format question instead.  How do you envision the checkboxes?
Hi Zachary,

I am thinking about two ways.
1. For the fruit column,  for each cell can we put apple, orange, banana, pear, and grape as 5 options and a checkbox in front of each option? So the respondents could pick as many fruit as they want for each time range.

2. In order to save some room, can we use drop down menu for fruit column just like the drop down menu for location? But the drop down menu could allow respondents to pick multiple options.

Please let me know if you think one way is doable or you have any suggestions on how to save room for this grid question. I just want to make the grid question look neat because my boss wants 48 time ranges. It will be a huge grid question. Many thanks for your help!
Implementing the first option should be fairly straightforward with the use of a free format question.

The second option is not formally supported in HTML.  You would need to implement a more advanced tool to create a multiple response dropdown.  A community library question item exists for select questions, but may require some changes to implement into a free format question:

https://www.sawtoothsoftware.com/community-question-library/1768-multiselect-dropdown
Thank you! Unfortunately, I am using version 8.4.8. Looks like I am not able to use the community library question. Please let me know if my understanding about could not use community library question is wrong.

For the first option, could you please provide me any document or anything in the forum that I could read about? Thanks again!

1 Answer

0 votes
 
Best answer
I'll help you set up the first row.  That should get you going.

Create a free format question.  You'll need three variables for each row.  For the first row, I created a combobox variable named "location1," a textbox variable named "whoate1," and a checkbox variable named "fruit1."  Each variable has some subsettings (require response, number of checkboxes, etc.); set these however you need them.

The basic HTML necessary for this first row is this:

<table>
    <tr>
        <td>
            Time Range
        </td>
        <td>
            Location
        </td>
        <td>
            Who Ate
        </td>
        <td>
            Fruit
        </td>
    </tr>
    <tr>
        <td>
            8:00 - 9:00 am
        </td>
        <td>
            <select name="[% QuestionName() %]_location1" id="[% QuestionName() %]_location1">
                <option selected value="">Default text</option>
                <option value="1">Home</option>
                <option value="2">Office</option>
                <option value="3">Vacation</option>
            </select>
        </td>
        <td>
            <input name="[% QuestionName() %]_whoate1" id="[% QuestionName() %]_whoate1" type="text" size="20">
        </td>
        <td>
            <table>
                <tr class="clickable">
                    <td class="input_cell">
                        [% CheckSelect(FreeFormatQ_fruit1, 1) %]
                    </td>
                    <td>
                        Apple
                    </td>
                </tr>
                <tr class="clickable">
                    <td class="input_cell">
                        [% CheckSelect(FreeFormatQ_fruit1, 2) %]
                    </td>
                    <td>
                        Orange
                    </td>
                </tr>
                <tr class="clickable">
                    <td class="input_cell">
                        [% CheckSelect(FreeFormatQ_fruit1, 3) %]
                    </td>
                    <td>
                        Grape
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>


"FreeFormatQ" should be replaced with the name of the question.
answered Dec 5, 2017 by Zachary Platinum Sawtooth Software, Inc. (81,800 points)
selected Dec 6, 2017 by Yolanda-Wong
Thank you so much for your help! It works perfectly!
...