Have an idea?

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

Grid Number logic check

Q1 Grid Numer , there are 300 rows and 3 columns.

                           Column 1        |        Column 2           |       Column 3     
Q1Row1 -    Input Number   |    Input Number    |   Input Number
Q1Row2 -    Input Number   |    Input Number    |   Input Number
Q1Row3 -    Input Number   |    Input Number    |   Input Number
.....
Q1Row300 -    Input Number   |    Input Number    |   Input Number

I want to check as below:

Q1Row1Col1+Q1Row1Col2+Q1Row1Col3=0 => Error Message
....
Q1Row300Col1+Q1Row300Col2+Q1Row300Col3=0 => Error Message

How could i fixed this?
asked Jan 27 by Saroeun Bronze (1,340 points)

1 Answer

0 votes
Try this code

for (var r = 1; r <= 300 && !strErrorMessage; r++) {

    Q1check=0;
    for (var c = 1; c <= 3 && !strErrorMessage; c++) {
        
        Q1check = Number(SSI_GetValue('Q1_r' + r + '_c' + c))+Q1check;
     
    }
     if ((Q1check==0)) {
            strErrorMessage = 'Error in '+r+" row";
        }
        else
        {
            strErrorMessage = "";
        }
       
}
answered Jan 27 by TarunKhanna Bronze (730 points)
Many thanks Fri,

If i have 2 column, i just change

c<=2, is it right?
Yes, that's right.
I have tested, it always show error "Error Row 1". However, i tried all condition. If it correct still show error.

Example:
Row1Col1=0 and Row1Col2=0 => Error Row 1
Row1Col1=0 and Row1Col2>0 => Error Row1
Row1Col1>0 and Row1Col2=0 => Error Row1
.....
...