Have an idea?

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

Multiple response / Single response Grid - JQuery issue

I have an older solution and am seeking a more up to date solution for Lighthouse Studio v9.3.0 for all devices.

I have a column direction grid (B0) with 2 columns and 11 rows.

Column 1 - multiple response (check boxes)
Column 2 - single response (radio buttons)

Upon load of the page, column 1 check boxes should be active and column 2 radio buttons should be inactive (greyed out). If an option is selected in column 1, the respective code will become active in column 2.

Thanks.
asked Mar 21, 2017 by Paul Moon Platinum (66,070 points)

1 Answer

0 votes
"Disable Graphical Inputs" adds simple JavaScript functions for enabling and disabling graphical radio buttons and checkboxes:

http://www.sawtoothsoftware.com/about-us/news-and-events/sawtooth-solutions/ss33-cb/253-support/software-downloads/question-library/1739-library-disable-graphical-inputs

You can then give the grid question this code:

<script>
$(document).ready(function(){
    var rowsList = $('input[name=hid_row_list_[% QuestionName() %]]').val().split(',').map(Number);
    rowsList.forEach(function(row){
        SSI_CustomGraphicalCheckbox(null, { name: '[% QuestionName() %]_r' + row + '_c1' }, SSI_GetValue('[% QuestionName() %]_r' + row + '_c1'));
    });
})

function SSI_CustomGraphicalCheckbox(graphicalObj, inputObj, bln) {
    var regex = /^[% QuestionName() %]_r([0-9]+)_c([0-9]+)$/;
    var match = inputObj.name.match(regex);
    if (match) {
        var row = Number(match[1]);
        if (bln) {
            SSI_EnableGraphicalInput('[% QuestionName() %]_c2_' + row);
        }
        else {
            if (SSI_GetValue('[% QuestionName() %]_c2') == row) {
                SSI_RadioReset('[% QuestionName() %]_c2');
            }
            SSI_DisableGraphicalInput('[% QuestionName() %]_c2_' + row);
        }
    }
}
</script>
answered Mar 21, 2017 by Zachary Platinum Sawtooth Software, Inc. (94,150 points)
Thanks Zachary for your prompt reply as always.

I copied your script into the footer of the grid question. When testing the question, I could not click on any check boxes in column 1 or a radio button in column 2. Column 2 was not deactivated either?

Have I misunderstood your instructions? Is there something I have missed?
Paul, I believe you need to download the "Disable Graphical Inputs" that Zach referenced and put that question on the same page IN ADDITION to putting that code in the footer.
Great, thanks Jay for the tip. Legend!!!

Got it to work. Misunderstood that initial part of the solution.

And thanks very much once again Zachary. It's a luxury to have your services so readily available. Greatly appreciated.
...