Have an idea?

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

How to focus on constructed list rather than parent?

I have a similar case but way simpler as I have a simple select question prior to a grid one.
Since we are pulling only the members selected at the Select question into the Grid question, my javascript verification is looking at all codes as is they were present.
How do you work that around? Below is my script which I repeat for each row.

if (SSI GetValue ("S4_r1_c1") == SSI GetValue("S4_r1_c2"))
{var strErrorMessage = "You can't select the same country as ''Main'' and ''Secondary''.";}

Thanks a lot
asked Jul 27, 2016 by Jack

2 Answers

0 votes
Are your grid variables defined correctly?

Should they be "S4_c1" and "S4_c2"? I am assuming a column direction grid here.

Try this Jack ...
if(SSI_GetValue("S4_c1")==SSI_GetValue("S4_c2"))
 {
  strErrorMessage="You can't select the same country as 'Main' and 'Secondary'.";
 }
else
 { 
  strErrorMessage="";
 }

Good luck mate.
answered Jul 27, 2016 by Paul Moon Platinum (76,175 points)
0 votes
Hi Jack. I believe your code wont work if 1 or more option is not selected in your select question. This is because the variables for that particular row wont get created in the grid question. Therefore, your JavaScript code would fail. I'm assuming that your rows are coming from a constructed list and columns are fixed. There are two ways of doing this.

The easier way -

if ([% ListHasParentMember(forGridQ,1) %] == 1)
{
  if (SSI GetValue ("S4_r1_c1") == SSI GetValue("S4_r1_c2"))
    {
      strErrorMessage = "You can't select the same country as 'Main' and 'Secondary'.";
    }
}


Where forGridQ is the constructed list in which the selected items of select question are coming(Press F1 in SSI and search for the explanation of this function). Repeat the above code for n number of rows.

There is one more method of doing this using arrays. Let me know if you are interested, I will post that too!

Thanks.
answered Jul 31, 2016 by Niks Bronze (620 points)
...