How to show labels based on the selection for a star rating question with 2 statements | XM Community
Skip to main content

I have a star rating question with 2 statements for people to rate. May I know how to show a label when a star is selected? I’ve pasted a JS code below but it doesn’t work. Wonder if this is because the JS code is for single statement and some adjustments need to be made to fit into a 2 statements question?

Besides, I have 2 languages supported for the survey, “EN”, “ZH-T”. “ZH-S” which I want to show the labels in the respective languages too. May I know how to set up the JS code to enable this?

{

jQuery('.StarsEventWatcher').on('touchend click',function(){

jQuery(".SatisfactionIndex").remove();
if($$('.ResultsInput')'0].value == 1){
$(this).parentNode.appendChild(QBuilder('div',{},'Bad'));
}else if($$('.ResultsInput')'0].value == 2){
$(this).parentNode.appendChild(QBuilder('div',{},'Poor'));
}if($$('.ResultsInput')'0].value == 3){
$(this).parentNode.appendChild(QBuilder('div',{},'Average'));
}if($$('.ResultsInput')'0].value == 4){
$(this).parentNode.appendChild(QBuilder('div',{},'Good'));
}if($$('.ResultsInput')'0].value == 5){
$(this).parentNode.appendChild(QBuilder('div',{},'Excellent'));
}
jQuery(".StarsContainer div:last").addClass("SatisfactionIndex");
jQuery(".SatisfactionIndex").css("font-size", "14px");
jQuery(".SatisfactionIndex").css("text-align", "center");
jQuery(".SatisfactionIndex").css("color", "rgb(153, 153, 153)");
    
});
    
});

Be the first to reply!

Leave a Reply