Have an idea?

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

Conditional display answer options

Hi,

I am currently busy with an ACBC. We have two selection questions before we start the ACBC, in order to determine the attributes that are going to be involved. In the first selection question we have two options. The second selection question has at max 7 options. However, out of those 7, 4 are depending on the answer of the first selection question.  I am struggling with the code, this is what I have so far:

ADD (parentlist,1)
add (parentlist,4)
add (parentlist,5)
Begin Unverified Perl
if (GETVALUE("Q1") == 1)
{
ADD ("parentlist",6);
ADD ("parentlist",7);
ADD ("parentlist",8);
ADD ("parentlist",9);
}  
End Unverified

It is not working, what am I doing wrong?
asked Jan 18 by SebastiaanNuij (120 points)

1 Answer

0 votes
Just checking in on a couple of issues here.

1/ Is Q1 a single response question or a multiple response question?

2/ Perl is case sensitive so we need to ensure your list name is entered exactly as you have defined it.

If Q1 is a single response question, try this ...
ADD(parentlist,1)
ADD(parentlist,4)
ADD(parentlist,5)

Begin Unverified Perl

 if(VALUE("Q1")==1)
 {
  ADD("parentlist",6,9);
 }  

End Unverified

If Q1 is a multiple response question, change the following ...
 if(VALUE("Q1")==1)

to ...
 if(VALUE("Q1_1")==1)

I have assumed your parent list is defined as "parentlist".
answered Jan 18 by Paul Moon Platinum (76,050 points)
Your suggestion is not giving the desired solution, too bad.

Q1 is a multiple repsonse question, I have replaced the name for the parentlist with " parentlist" in this message, but the spelling is correct.
At Q2, do you want codes 6-7-8-9 to appear only if Q1 code 1 is selected?

Ensure your parent list is spelt correctly and you are applying the correct case for the list name.

And are you using ...
if(VALUE("Q1_1")==1)
If you can't get it working, I can send you an example ssi file that does work.

Let me know.
I indeed want 6-9 to appear if Q1 is at least 1, can also be 1 or 2. I have sent you a personal message regarding the example file.
I have sent you a test ssi file I quickly whipped up. Check your email. This demo works fine. Let me know you are okay with it.

Thanks.
Inspirated by your file I found the mistake. The parentlist for Q1 was a constructed list, where option 1 was attribute 2. So by changing Q1_1 to Q1_2, it was resolved. Thanks!
Good to hear your problem is now resolved. Well done.

These issues will only benefit you the next time you come across this type of problem. A good learning experience my friend.
...