Have an idea?

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

Appear question based on previous question selection

Hi,

Can someone please help me write a code for the following scenario?

There are 2 questions in one page (Q40 and Q41). Q41 has to only appear if any options are selected in Q40. Q40 is a multi select question.

Also where do I insert this code?

Thank you!
asked Jun 25 by AJ

1 Answer

0 votes
If you look to the Question Library on the Sawtooth Software website, you will find a Branching feature.

This enables you to have multiple questions on the same page, and only display the 2nd question based on a particular response in the 1st question.

You will need to download the ZIP file and import it in to your very own question library.

Follow the step-by-step instructions in the question footer.

Here's the link ...

https://sawtoothsoftware.com/resources/question-library/branching
answered Jun 25 by Paul Moon Platinum (94,725 points)
Once you've added Branching and the Better Lighthouse Library to your questionnaire, I believe the Branching settings should look like this:

    branchings: [
        {
            dependentQuestion: 'Q41',
            condition: function() {
                var selectQ = 'Q40';
                var items = $('input[name="hid_list_' + selectQ + '"]').val().split(',');
                for (var i = 0; i < items.length; i++) {
                    if (SSI_GetValue(selectQ + '_' + items[i])) {
                        return true;
                    }
                }
                return false;
            },
            requireResponse: true
        }
    ],
...