Have an idea?

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

toggle grid rows with non-graphical radiobuttons

Hi all,

The following code works great for toggling grid rows if you are using graphical buttons . . . what do I need to change for it to work with regular radiobuttons?

[code]
<script>
$(document).ready(function(){
    hideAllOtherQ();
})
 
function SSI_CustomGraphicalRadiobox(graphicalRadioboxObj, inputObj) {
    if (inputObj.name == 'S6_r1') {
        switch (Number(inputObj.value)) {
            case 1: case 2:
                $('#S6_r2_row').show();
                break;
        }
    }
    if (inputObj.name == 'S6_r2') {
        switch (Number(inputObj.value)) {
            case 1: case 2:
                $('#S6_r3_row').show();
                break;
        }
    }

}
 
function hideAllOtherQ() {
    $('#S6_r2_row').hide();
    $('#S6_r3_row').hide();
}
</script>
[code]

Thanks for any help!
asked Mar 18, 2017 by jas8278 Bronze (750 points)

1 Answer

+2 votes
jQuery's change and click events can help us in place of SSI_CustomGraphicalRadiobox.  Put this code in S6's footer:

<script>
$(document).ready(function(){
    $('#S6_r2_row, #S6_div .mobile_grid_card[data-card_num=2]').hide();
    $('#S6_r3_row, #S6_div .mobile_grid_card[data-card_num=3]').hide();
    updateS6Rows();
    $('input[type=radio]').change(updateS6Rows);
    $('.clickable').click(updateS6Rows);
})

function updateS6Rows() {
    var interval = setInterval(function(){
        for (var row = 1; row <= 2; row++) {
            var val = SSI_GetValue('S6_r' + row);
            if (val == 1 || val == 2) {
                $('#S6_r' + (row + 1) + '_row').show();
                $('#S6_div .mobile_grid_card[data-card_num=' + (row + 1) + ']').show();
            }
        }
        clearInterval(interval);
    }, 50);
}
</script>
answered Mar 20, 2017 by Zachary Platinum Sawtooth Software, Inc. (129,350 points)
Perfect - thanks Zachary!
Can this be done for randomized rows in a grid?
...