Have an idea?

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

hide/show responseoptions in grid

Hi,

I would like to show different answer options in the rows of a grid question based on previous responses:
a) show only if Q1 = 1
b) show only if if Q2 =1
c) all
d) all
e) all
f) all
g) all


I used the following code:

Begin Unverified Perl
if (GETVALUE('Q1') == 1)
    ADD('List1', 1);
}
if (GETVALUE('Q2') == 1) {
    ADD('List1', 2);
}
End Unverified
Add (List1, 3)
Add (List1, 4)
Add (List1, 5)
Add (List1, 6)
Add (List1, 7)

Randomize()

However, I get a script error when trying to use this code. What am I doing wrong?
asked Mar 3 by Jeroen

1 Answer

0 votes
This should sort your problems out ...
Begin Unverified Perl

if (GETVALUE("Q1")==1)
 {
  ADD("List1",1);
 }

if (GETVALUE("Q2")==1)
 {
  ADD("List1",2);
 }
 
End Unverified

ADD(List1,3,7)
Randomize()

A couple of issues I spotted ...

1/ You had a missing beginning curly bracket "{" on your first IF statement (before the "ADD" command).
2/ Use double quotes in Perl Script.
3/ Ensure all your question and list names are typed exactly as you have defined them as Perl is case sensitive.
4/ Based on your script, it is assuming Q1 and Q2 are single response select type questions. If they are multiple response, use Q1_1==1 and Q2_1==1.
answered Mar 3 by Paul Moon Platinum (89,880 points)
...