Have an idea?

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

Add a numeric column (age) in a multi-select Grid question.

Hello

I have a multi-select Grid question (Q1) with 3 columns.

People can select 0, 1 ,2 or 3 checkboxes per row.

I would like to add an additional column (before the 3 columns) for Age (0 - 17 max).

The age value should  be required if they tick any of the 3 options in a row, but not required if a row has no options selected.

Is that possible?

thanks
Dan
asked Mar 3 by dan r Bronze (2,790 points)

1 Answer

0 votes
You'll need to use two grid questions, the first non-required numeric with one column and the second checkbox with three columns.  You can combine the two of them with the code here:

https://legacy.sawtoothsoftware.com/forum/28890/add-text-boxes-to-grid

Then give the first grid question this custom JavaScript verification:

var secondGrid = $('#[% QuestionName() %]_div').nextAll('.grid').get(0).id.replace(/_div$/, '');
var secondGridColumns = $('input[name="hid_col_list_' + secondGrid + '"]').val().split(',');
$('input[name="hid_row_list_[% QuestionName() %]"]').val().split(',').forEach(function(row){
    if (!SSI_GetValue('[% QuestionName() %]_r' + row + '_c1')) {
        secondGridColumns.forEach(function(column){
            if (SSI_GetValue(secondGrid + '_r' + row + '_c' + column)) {
                strErrorMessage = 'your error message...';
            }
        });
    }
});
answered Mar 3 by Zachary Platinum Sawtooth Software, Inc. (171,525 points)
Thanks Zachary, I'll get on with trying to implement this and report back
....
Update.....Works perfectly , thank you Zachary
Dan
...