Is there any way you can display the order of answers differently per language?
Thank you
Best answer by TomG
View originalBest answer by TomG
View originalhttps://www.qualtrics.com/community/discussion/comment/23399#Comment_23399JodieG hi, I'm also implementing a survey in 10 languages. Were you able to resolve this for the 10 translations?
https://www.qualtrics.com/community/discussion/comment/23399#Comment_23399The following JavaScript worked for me. It will grab the language currently selected in Qualtrics by the survey respondent and works with single choice, multiple answer, dropdowns, and select boxes.
/* Tweak to ensure dropdowns are sorted in other languages */
// Pull choices from current question
let targetElement = this.getChoiceContainer();
let myChoices = targetElement.children;
myChoices = Array.prototype.slice.call(myChoices);
// Sort choices
myChoices.sort(function(a, b) {
return a.textContent.localeCompare(b.textContent, '${e://Field/Q_Language}', {sensitivity: 'base', ignorePunctuation: true, numeric: true});
});
// Return choices to current question
for (let i=0; i < myChoices.length; i++) {
targetElement.appendChild(myChoices[i]);
}
https://www.qualtrics.com/community/discussion/comment/33043#Comment_33043It's fine if you only want to sort French.
Since the original post several months ago, I've written a JS function that provides a more robust solution (not free). It alphabetizes multiple choice questions (vertical single answer, vertical multi-answer, dropdown list, select box and multi-select box) on-the-fly based on the current language. It also supports anchored choices.
If anyone is interested, feel free to contact me by private message.
https://www.qualtrics.com/community/discussion/comment/33045#Comment_33045Hey Tom, good point. I make a tweak to the above so it works with the language currently selected in Qualtrics by the survey respondent.
https://www.qualtrics.com/community/discussion/comment/23399#Comment_23399The following JavaScript worked for me. It will grab the language currently selected in Qualtrics by the survey respondent and works with single choice, multiple answer, dropdowns, and select boxes.
/* Tweak to ensure dropdowns are sorted in other languages */
// Pull choices from current question
let targetElement = this.getChoiceContainer();
let myChoices = targetElement.children;
myChoices = Array.prototype.slice.call(myChoices);
// Sort choices
myChoices.sort(function(a, b) {
return a.textContent.localeCompare(b.textContent, '${e://Field/Q_Language}', {sensitivity: 'base', ignorePunctuation: true, numeric: true});
});
// Return choices to current question
for (let i=0; i < myChoices.length; i++) {
targetElement.appendChild(myChoices[i]);
}
wow, this worked amazingly well - thank you for sharing!
one question: is there a way to exclude answer options like ‘other’ or ‘none of these’ from the sorting? I appreciate any leads :)
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.