Have an idea?

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

Number of columns dependant on number of options

Hi ... I have a question with a lot of codes.  The initial question displays these in four columns.

I have a followup question where the options are dependant on what was chosen in the initial one.  Because of the number of possible options, this one is also displayed in four columns.  

BUT this looks uncool if only 2 or 3 options need to be displayed.  In this case, just one column would suffice.

Anyone got any idea of how I can code it so that options would tick over to a new column if x number of options need to be displayed?

Does this make sense?
asked Nov 24 by Marion Bronze (3,690 points)

1 Answer

+1 vote
Adding this script to your select question will move all items into the first column under specified circumstances:

<script>
$(document).ready(function(){
    var count = $('input[name="hid_list_[% QuestionName() %]"]').val().split(',').length;
    if (count <= 3) {
        $('#[% QuestionName() %]_div .response_column:first-child').append($('#[% QuestionName() %]_div .response_row'));
        $('#[% QuestionName() %]_div .response_column:not(:first-child)').remove();
    }
})
</script>


Does that serve your needs?
answered Nov 25 by Zachary Platinum Sawtooth Software, Inc. (129,150 points)
Awesome!  Thanks a bunch!
...