Have an idea?

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

ACBC screener task with dynamic text option

I have an ACBC screening task with 4 holiday destinations. Each destination has a number of attributes with the first attribute being location. At the bottom instead of having 'Something I could consider' 4 times, I would like to show the first attribute  and have 'I could consider going to [LOCATION]'.  I don't know how to refer to these locations. Can't see any perl functions that display attribute labels for ACBC. Can someone please help?
asked Aug 24, 2020 by Paul Kallis (250 points)

1 Answer

0 votes
 
Best answer
Please try adding this script to your Screener questions:

<script>
$(document).ready(function(){
    var tbody = $('#[% QuestionName() %]_div .inner_table > tbody');
    var columns = Number($('input[name="hid_[% QuestionName() %]_num_cols"]').val());
    for (var c = 1; c <= columns; c++) {
        var firstAttributeLevel = $(tbody).find('> tr:first-child > td:nth-child(' + (c + 1) + ')').text().trim();
        var newText = 'I could consider going to ' + firstAttributeLevel;
        $('label[for="[% QuestionName() %]_' + c + '_1"]').text(newText);
    }
})
</script>


Line 7 can be updated with the nature of the acceptable text.
answered Aug 24, 2020 by Zachary Platinum Sawtooth Software, Inc. (174,325 points)
selected Aug 24, 2020 by Paul Kallis
Thank you Zachary!
Sorry one last thing. The code works in the concept acceptance label but if I try to put this code in the  concept rejection label, it is blank and overwrites the acceptance label?
That script doesn't need to be placed in either label.  Most anywhere in the Screener question should work.

To apply to the rejection label, line 8 just needs to reference "_2" instead of "_1."
...