Have an idea?

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

Grid row open-end direction with 3 alternative columns answer

Good afternoon,

I would like to create a grid with some rows and 3 alternative columns: hours a day / hours a week / hours a month.
Respondents would answer only in 1 columns and leave the others blank.
Is there any way to construct this kind of grid?

Many thanks in advance
Maite
asked Oct 22 by Maite (200 points)
What exactly does it mean that a respondent only answers one column?  When one column has text, are the others disabled?  Or when one column is typed into, the others are automatically cleared?  Or perhaps an error message shows up if the respondent attempts to submit the page with multiple columns answered?
Hi Zachary,
Many thanks for your quick reply.

I did not explain well what we need.
We want that respondents could answer only in  one column for each row. They could chouse in which column they want type into.

For example:

How many time do you use any of the following devices:
                                       hours per day                   hours per week               hours per  month
- Mobile                                    3
- Tablet                                                                                      2
 - Smart TV                                                                                                                                   1
...
I understand that, but what behavior are you imagining to prevent a user from not doing this?  If I'm a respondent taking your survey and I try to answer two fields in the same row, what happens?  Would having the page display an error when I try to submit the page like this be enough?
Yes, an error should be enough or disable the others options in the row if possible.
Hi Zachary,
Could it be possible to add a difeferent validation for each column (grid row oriented)? For example, in first column admit only values 1 to 24, in second column values 1 to 168,...
thanks in advance,
Maite
Try out this:

$('input[name="hid_row_list_[% QuestionName() %]"]').val().split(',').forEach(function(row){
    if (SSI_GetValue('[% QuestionName() %]_r' + row + '_c1') > 24) {
        strErrorMessage = 'First column must be 24 or under.';
    }
    if (SSI_GetValue('[% QuestionName() %]_r' + row + '_c2') > 168) {
        strErrorMessage = 'Second column must be 168 or under.';
    }
});
It works. Thank you again

1 Answer

0 votes
This custom JavaScript verification will require that exactly one column be responded to for each row:

var rows = $('input[name="hid_row_list_[% QuestionName() %]"]').val().split(',');
var columns = $('input[name="hid_col_list_[% QuestionName() %]"]').val().split(',');

for (var r = 0; r < rows.length && !strErrorMessage; r++) {
    var row = rows[r];
    var resps = 0;
    columns.forEach(function(column){
        if (SSI_GetValue('[% QuestionName() %]_r' + row + '_c' + column)) {
            resps++;
        }
    });
    if (resps != 1) {
        strErrorMessage = 'Exactly one response must be provided for each row.';
    }
}
answered Oct 22 by Zachary Platinum Sawtooth Software, Inc. (156,375 points)
It works perfect!!
Thank you very much
...