Have an idea?

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

Numeric Grid question where the one entered value can not exceed another


I'm trying to add in a bit of script to the Sawtooth Price VW sensitivity meter question (which I am using in conjunction with choice) and I want to restrict the question so people have to answer in ascending order. It's a grid question with numeric entry and I want Q1_1 to be the first entered value and Q1_2 the next entered  value. I don't want respondents to be able to enter a Q1_2 value that is lower than the Q1_1 value. and so on for Q1_3 not being able to be lower than Q1_2 etc.

Is there a piece of script that can cause this to bring up an error?
asked Oct 16, 2017 by Jasha Bowe Bronze (1,725 points)
retagged Oct 16, 2017 by Walter Williams

1 Answer

0 votes
Try setting the custom JavaScript verification to this:

var rows = $('input[name="hid_row_list_[% QuestionName() %]"]').val().split(',').map(Number);
var prev = SSI_GetValue('[% QuestionName() %]_r' + rows[0] + '_c1');
for (var r = 1; r < rows.length; r++) {
    var curr = SSI_GetValue('[% QuestionName() %]_r' + rows[r] + '_c1');
    if (curr < prev) {
        strErrorMessage = 'Error message.';
    prev = curr;
answered Oct 16, 2017 by Zachary Platinum Sawtooth Software, Inc. (207,200 points)