Have an idea?

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

Force order of codes to display across instead of down

I have a list of codes in a multiple response question and I want them to display across instead of the default down. When I set them to 3 columns.

For example,  I want the codes to be shown in this order
row 1   code 1, code 2, code 3
row 2   code 4, code 5, code 6

As default, codes are displayed down the page in this order
row 1   code 1, code 3, code 5
row 2   code 2, code 4, code 6

Also, I noticed that when I set the 3 columns and there are say 4 codes shown instead of 6 it re-displays into 2 columns. How do I override so always display across 3?

Thanks for any help. Hoping it's an easy fix!
asked Oct 24, 2018 by TGE018 (200 points)

1 Answer

0 votes
What Lighthouse is doing is taking the total number of items, dividing that by the number of columns, then rounding up.  This is how it knows how many rows it needs.  Four items and three columns means that we need two rows to display all the items.  The quirky behavior comes from the fact that Lighthouse fills the multiple-column select question column-by-column, so it puts two items in the first column, two items in the second column, and then is all out of items when it reaches the third column.

But all of this can be changed with a little JavaScript.  Try adding this script to your select question:

    if (!$('#[% QuestionName() %]_div .mobile_select').length) {
        var items = $('input[name="hid_list_[% QuestionName() %]"]').val().split(',');
        var columns = $('#[% QuestionName() %]_div .response_column').length;
        for (var i = 0; i < items.length; i++) {
            var item = items[i];
            var column = i % columns + 1;
            $('#[% QuestionName() %]_div .response_column:nth-child(' + column + ')').append($('#[% QuestionName() %]_' + item).closest('.response_row'));
answered Oct 24, 2018 by Zachary Platinum Sawtooth Software, Inc. (120,400 points)
Fantastic that's done what I need. Thank you!