Have an idea?

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

Show label in the same page in grid

Can i use this script in grid for select Dropdown?

<script>
$(document).ready(function(){
    updateSelectedText();
})
 
function SSI_CustomGraphicalRadiobox() {
    updateSelectedText();
}
 
function updateSelectedText() {
    var selectQuestion = 'SelectQ';
    var responseOptions = [% ListLabelsArray(List1) %];
    $('.mySelectedText').text(responseOptions[SSI_GetValue(selectQuestion) - 1]);
}
</script>

Note: I have used this script in my grid question but it working while I select another radio select. it wasn't working when I select answer from dropdown list.

Is it possible?
asked Feb 6 by Saroeun Bronze (1,945 points)

1 Answer

+1 vote
 
Best answer
SSI_CustomGraphicalRadiobox is triggered when a graphical radio button changes states.  We'll want to replace those three lines with something that will trigger when a dropdown changes state, instead:

$('#SelectQ').change(updateSelectedText);


Assuming this code is being placed in the select question, I would also recommend replacing both instances of "SelectQ" with "[% QuestionName() %]" so the code will keep working even if the question is renamed.
answered Feb 6 by Zachary Platinum Sawtooth Software, Inc. (144,125 points)
selected Feb 6 by Saroeun
Thanks,

Could you give me full script? I don't understand where i need to revise.
Replace this with my code above:

function SSI_CustomGraphicalRadiobox() {
    updateSelectedText();
}
Many Thanks,

Here my final script:
<script>
$(document).ready(function(){
    updateSelectedText();
})
 
$("#Q3x555_r2_c1").change(updateSelectedText);
 
function updateSelectedText() {
    var selectQuestion = "Q3x555_r2_c1";
    var responseOptions = [% ListLabelsArray(Q3cDropdownList) %];
    $('.mySelectedText').text(responseOptions[SSI_GetValue(selectQuestion) - 1]);
}
</script>
...