Have an idea?

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

Live Answer in a Max Diff Exercise

Hello there,

I am preparing a MaxDiff task and I want the respondent to see his "Best" and "Worst" answers beneath the Task, to confirm his choices. I found the above code in the forum for radio select questions, is it possible to modify it to conduct the function I want to do? how could this be done?

On the other hand, When I input the Levels in the MaaxDiff exercise should I give each level a label name that is the same of the level itself so that the (text) of the level appears or leaving the label blank will do the same job?

Finally,I want to have an assurance question like (are the above levels your final choice? yes/no) and based on this question the respondent will continue or repeat the question. what is the best way to include such a question?
related to an answer for: Using answer label on same page
asked Mar 28 by AMYN Bronze (1,335 points)
Are you talking about setting Internal Labels for your list items?

What are you imaging for an assurance question?  Is it on the same page as the MaxDiff task?  Does it auto-submit when respondents click "Yes"?  Does it reset the page when respondents click "No"?
Hi Zachary,

So I do not really know what is (Internal Labels ) mean? [unless it is the bar under the original item where I could set a Label for my item to make it easier and more meaningful during the analysis]

What I know is that I can retrieve the answer of a question on the next page by writing the [%question_name%], and this will retrieve a numeric value for most questions [MaxDiff or CBC specifically]. What I want to do is:
1- Retrieve the MaxDiff answer on the same page of the question (one for the Best & one for the Worst choices)
2- The result should be the original text chosen by the respondent and not the numeric value of the item itself.

So after the message indicating the choices made by the responder, the question appears as (are you sure these are your choices?)
1- Yes; Result will be moving to the next page
2- No; Result will be reset the question.
I made an assurance Question in the CBC exercise part before but it was on a separate page, the retrieval of the results were numeric values (the number of the chosen concept), I used the skip logic to direct the respondent to the specific page based on their answer and I added a box that let them know that they will be repeating certain questions depending on their answer. So this time I want a better solution for this issue.

And on a side, could you tell me the code of this solution would be Html or java? I want to learn some of these programming languages to try to solve these problems myself in the future, for the meanwhile will be seeking your precious support.

N.B. let me know how could I address you properly, as I will mention you in the acknowledgments when I finish this project - not very soon but should happen eventually-.

Thanks very much
That input box beneath the regular list item label is the Internal Label, yes.  If that's not what you meant in your "On the other hand" paragraph, then I don't think I understand what you mean in that part.

Most web programming is done in the JavaScript language, not to be confused with the unrelated Java language.

1 Answer

+1 vote
Please try adding a select question immediately following your MaxDiff task.  Mine had a "yes" first option and "no" second option.  Add these wherever in the question text you want the item labels to appear:

<span class="bestItem"></span>


<span class="worstItem"></span>


Finally, add this script to the select question:

<style>
#[% QuestionName() %]_div {
    display: none;
}
</style>

<script>
$(document).ready(function(){
    SSI_RadioReset('[% QuestionName() %]');
    updateMaxDiffConfirmationQuestion();
})

function SSI_CustomGraphicalRadiobox() {
    updateMaxDiffConfirmationQuestion();
}

function updateMaxDiffConfirmationQuestion() {
    // Parameters
    var labels = [% ListLabelsArray(list1) %];

    // Run
    var maxDiffTask = $('#[% QuestionName() %]_div').prevAll('.question.maxdiff').eq(0).attr('id').replace(/_div$/, '');
    switch (SSI_GetValue('[% QuestionName() %]')) {
        // Refresh confirmation question
        case 0:
            var best = SSI_GetValue(maxDiffTask + '_b');
            var worst = SSI_GetValue(maxDiffTask + '_w');
            if (best && worst && best != worst) {
                $('.bestItem').text(labels[best - 1]);
                $('.worstItem').text(labels[worst - 1]);
                $('#[% QuestionName() %]_div').show();
            }
            else {
                $('#[% QuestionName() %]_div').hide();
            }
            break;
    
        // Submit page
        case 1:
            SSI_SubmitMe();
            break;
        
        // Reset page
        case 2:
            $('#[% QuestionName() %]_div').hide();
            if (SSI_GetValue(maxDiffTask + '_b')) {
                SSI_RadioReset(maxDiffTask + '_b');
            }
            if (SSI_GetValue(maxDiffTask + '_w')) {
                SSI_RadioReset(maxDiffTask + '_w');
            }
            if (SSI_GetValue('[% QuestionName() %]')) {
                SSI_RadioReset('[% QuestionName() %]');
            }
            break;
    }
}
</script>


"list1" must be replaced with the name of the list used in the MaxDiff, or the name of the parent list in the case that the MaxDiff uses a constructed list.
answered Mar 29 by Zachary Platinum Sawtooth Software, Inc. (127,900 points)
Thank you very much, that worked as required. The only point is that the item label appears with its HTML formatting, that is, for example, the bold label (<b>....</b>), I tried to remove that in the internal label assuming that this what will appear instead but that did not work. how could I solve this formatting issue?
The easiest option might be to use a copy of your list that doesn't have any formatting and have this code point to that list.
...