Have an idea?

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

programming logic for select question

I have a question C6 that has six responses but I only want response 1 to appear if the response to another question, C3 was 1 or 3. I only want response 2 to appear if the  response 2 or 3 was selected in question C3.

How can I do this?
asked Feb 26 by anonymous
Are these questions on different pages?
yes they are on different pages

1 Answer

0 votes
You will need to use a constructed list.  The constructed list's parent list should be the list used for C3.  The instructions for the constructed list depend on whether C3 is multi-select.

Single-select:

Begin Unverified Perl
my $c3 = GETVALUE('C3');
if ($c3 == 1 || $c3 == 3) {
    ADD('list1', 1);
}
if ($c3 == 2 || $c3 == 3) {
    ADD('list1', 2);
}
ADD('list1', 3, 6);
End Unverified


Multi-select:

Begin Unverified Perl
if (GETVALUE('C3_1') || GETVALUE('C3_3')) {
    ADD('list1', 1);
}
if (GETVALUE('C3_2') || GETVALUE('C3_3')) {
    ADD('list1', 2);
}
ADD('list1', 3, 6);
End Unverified


"list1" must be replaced with the name of the parent list.

Finally set C6 to use this list.
answered Feb 26 by Zachary Platinum Sawtooth Software, Inc. (121,625 points)
the question is being completely skipped when I test it... any idea what might be causing that to happen?

When I try to 'skip to' that question it still skips over it to the next question

Begin Unverified Perl
my $c5a = GETVALUE('C5a');
if ($c5a == 1 || $c5a== 3) {
    ADD('c6listpre', 1);
}
if ($c5a == 2 || $c5a == 3) {
    ADD('c6listpre', 2);
}
ADD('c6listpre', 3, 6);
End Unverified
We must not be on the same page in some way.  Would it be possible for you to send in a .ssi demonstrating the problem to support@sawtoothsoftware.com?  Of course, irrelevant or sensitive information can be removed from the file before sharing it.
In the constructed list's instructions, be sure to use "c6list1PRE" instead of "c6listpre."  Please also make sure a page break exists between the two questions.
...