Have an idea?

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

Limit grid responses based on others in the grid (ie. only 1 "preferred model")

I have a grid question 11x4. The rows are different models and the columns are preferences. Radio button responses, but for the 4th column "My preferred model" I want to stop them from selecting it more than once (they don't have to have a preferred model, I just don't want them to have more than 1).

I think I have to use JavaScript Verification but I have no idea how to do that
asked Jan 11 by KevinB

1 Answer

0 votes
Custom JavaScript verification is correct.  Try using this:

// Parameters
var exclusiveColumn = 4;
var errorMessage = "Multiple items cannot be selected for the last column.";

// Run
var found = false;
$('input[name="hid_row_list_[% QuestionName() %]"]').val().split(',').forEach(function(row){
    if (SSI_GetValue('[% QuestionName() %]_r' + row) == exclusiveColumn) {
        if (found) {
            strErrorMessage = errorMessage;
        }
        found = true;
    }
});
answered Jan 11 by Zachary Platinum Sawtooth Software, Inc. (202,850 points)
...