Have an idea?

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

Single Select Question - Hide "Don't Know / Refused" until they try to skip the question

Hey Zach,

We figured this out for grid questions (<a href="https://legacy.sawtoothsoftware.com/forum/28158/hide-dont-know-refused-until-they-try-to-skip-the-question">see here</a>) so now trying to do the same thing for single select questions. I want to hide don't know/refused options and only make them visible if a respondent clicks on "next" having not answered the question.

For the example below I'm just using a Yes/No response list.
1=Yes
2=No
3=Don't know
4=Refused.

I tried to steal some code from our earlier discussion, but it's not working.  I think initially it's because I'm unsure how to reference the response options I need to hide (3 and 4).  I did some poking around in the forums and found <a href="https://legacy.sawtoothsoftware.com/forum/18391/want-to-give-alternate-colouring-to-single-select-respondes?show=18391#q18391">this question</a> on formatting and it used the styling from it. Even when I run just that part and comment out the script, "rows" 3 and 4 are still displayed.

<!--hiding dk/ref-->
<style>
#[% QuestionName() %]_div .response_row(3), <--my "don't know" option/selection/row in this example-->
#[% QuestionName() %]_div .response_row(4)    {  <--my "refused" option/selection/row in this example-->
    display: none;
}
</style>

<script>
$(document).ready(function(){
    var resp = SSI_GetValue('[% QuestionName() %]');
    if (resp == 3 || resp == 4) {
        for (var i = 3; i <= 4; i++) {
            $('#[% QuestionName() %]_div .response_row(' + (i + 1) + ')').show();
        }
    }
})
</script>

asked Dec 18, 2020 by Nwiggin Bronze (1,310 points)
I think you've missing some use of ":nth-child."

#[% QuestionName() %]_div .response_row:nth-child(3)

Your solution to the original question

Please only use this to answer the original question. Otherwise please use comments.
Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

To avoid this verification in future, please log in or register.
...