Have an idea?

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

Hiding prohibited combination in ACBC BYO

I have two price levels, monthly rate & promotional rate. I have implemented prohibitions such that the promotion rate must always be less than the monthly rate. In the BYO all levels of price show. I would like the levels of promotional price that are prohibited to be hidden once the respondent select the monthly rate they prefer. (Similar to how alternative-specific attributes function when the relevant levels are selected)

Thanks!
asked Jan 31 by KKing (140 points)

1 Answer

0 votes
Try this:

<script>
$(document).ready(function(){
    updateAcbcByoProhibitions();
})

function SSI_CustomGraphicalRadiobox(){
    updateAcbcByoProhibitions();
}

function updateAcbcByoProhibitions() {
    var independentAttribute = 2;
    var dependentAttribute = 3;
    var prohibitions = {
        1: [1, 2],
        2: [2, 3],
        3: [3, 4]
    };
    
    var independentValue = SSI_GetValue('[% QuestionName() %]_' + independentAttribute);
    var dependentValue = SSI_GetValue('[% QuestionName() %]_' + dependentAttribute);
    $('#[% QuestionName() %]_row_' + dependentAttribute + ' .clickable').show();
    var prohs = prohibitions[independentValue];
    if (prohs) {
        prohs.forEach(function(proh){
            $('#[% QuestionName() %]_' + dependentAttribute + '_' + proh).closest('.clickable').hide();
        });
        if (prohs.indexOf(SSI_GetValue('[% QuestionName() %]_' + dependentAttribute)) != -1) {
            SSI_RadioReset('[% QuestionName() %]_' + dependentAttribute);
            $('#[% QuestionName() %]_price' + dependentAttribute).val(0);
            var sum = 0;
            $('[id^=[% QuestionName() %]_price]').each(function(){
                sum += Number($(this).val()) || 0;
            });
            $('#[% QuestionName() %]_div .total_price input').val(sum);
        }
    }
}
</script>


Line 11 should be updated with which attribute is the monthly rate.  Line 12 should be updated with which attribute is the promotional rate.

Lines 14-16 should be updated with the prohibitions.  Currently, the first monthly rate prohibits the first and second promotional rates, the second monthly rate prohibits the second and third promotional rates, and the third monthly rate prohibits the third and fourth promotional rates.
answered Jan 31 by Zachary Platinum Sawtooth Software, Inc. (69,875 points)
Thank you! This worked perfectly!
...