Have an idea?

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

Select top score depend on previous question

Dear All,

i have 2 questions as below:

Q1-Numberic questions.
Q2-Grid question that have 8 rows and 6 columns (score 1 to 6).

I want to check with these 2 questions if Invalid show error message.

Example:
If Total Q1=3 ---> Q2 can select score 5 or 6 must be Less than or equal Total Q1.

Could anyone help me to fix this?
asked Jul 10 by Saroeun Bronze (940 points)
retagged Jul 10 by Walter Williams
What type of grid is this?  Checkboxes?  The respondent can select up to Q1 checkboxes for each row of the grid?
Sorry, let me explain again.

Q1: Grid question as Numeric format type. Row1 and Row2
Q2: Grid question as Select format type. Their answer as score 1 to 6.
Row1 can select score 1 to 6.
Row2 can select score 1 to 6.
Row3 can select score 1 to 6.
....
Row8 can select score 1 to 6.

I want to check logic for score 5 or 6.

Example:
If Total Q1=3 ---> There are only 3 rows in Q2 can select score 5 or 6. And another Row in Q2 can select only score 1 to 4.
I'm still missing something.  The total of the two responses to Q1 defines the number of rows in Q2?  Where is the 5 through 6 range and the 1 through 4 range coming from?
Q1: Answer :
Q1_r1 input number
Q1_r2 input number

Q2: Answer (there are 6 scores)
Q2_r1 select code 1,2,3,4,5,6
Q2_r2 select code 1,2,3,4,5,6
Q2_r3 select code 1,2,3,4,5,6
Q2_r4 select code 1,2,3,4,5,6
Q2_r5 select code 1,2,3,4,5,6
Q2_r6 select code 1,2,3,4,5,6
Q2_r7 select code 1,2,3,4,5,6
Q2_r8 select code 1,2,3,4,5,6

I want to count code 5 and 6 in Q2 must be Less than or equal Total number in Q1.

Hope you understand. Thanks

1 Answer

+2 votes
 
Best answer
Custom JavaScript verification for Q2:

var max = [% Q1_r1_c1 + Q1_r2_c1 %];
var count = 0;
for (var row = 1; row <= 8; row++) {
    if (SSI_GetValue('[% QuestionName() %]_r' + row) >= 5) {
        count++;
    }
}
if (count > max) {
    strErrorMessage = 'Error.';
}


Replace both "Q1" with the name of the first question.
answered Jul 10 by Zachary Platinum Sawtooth Software, Inc. (63,900 points)
selected Jul 10 by Saroeun
Many thanks.
...