Have an idea?

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

perl constructed list

Hi,
I have a multi select question with 4 alternatives. If you choose 1, 2 or 3 then you will get a new question that shows alternative 1 if you chose 1, 2 if you chose 2 and also 3 if you chose 3. These alternatives are formulated different so they are another list. I tried to use this constructed list in the second question, but I get an error. Do you know how to make it work?
 Thanks

So Q7a is the first question while the parent list is the second question

Begin Unverified Perl
if(VALUE("Q7a_1")=1){ADD(PARENTLISTNAME(),1);}
if(VALUE("Q7a_2")=1){ADD(PARENTLISTNAME(),2);}
if(VALUE("Q7a_3")=1){ADD(PARENTLISTNAME(),3);}
End Unverified
asked Jan 8 by Linebje (420 points)

1 Answer

0 votes
You are very close.  You need == instead of = and you need to include the actual name of the parent list in quotes.  With the below code you need to replace ParentListName with the actually list name.  That should get you what you need.

Begin Unverified Perl
if (VALUE("Q7a_1")==1)
{ADD("ParentListName",1);}
if (VALUE("Q7a_2")==1)
{ADD("ParentListName",2);}
if (VALUE("Q7a_3")==1)
{ADD("ParentListName",3);}
End Unverified
answered Jan 8 by Jay Rutherford Gold (41,760 points)
Actually, I believe you can use the PARENTLISTNAME as you have it, but I've not typically done that.  The problem may have only been with the ==, but you can test it.
Great, thanks :)
...