I have many multiple-choice questions with four options. I need to update them all to have the prefixes A., B., C., D. before each option. I'm thinking the easiest way to do this en masse would be to paste javascript into each question instead of updating all of the choice texts.
How can I add A, B, C, and D to the options in my multiple choice questions using JS?
Solved
Prepend Text to Multiple Choice Question Options
Best answer by ahmedA
If you want to apply it to all questions, then add this to your header:
Qualtrics.SurveyEngine.addOnReady(function () {
let choices = document.querySelectorAll("span [for].MultipleAnswer,span [for].SingleAnswer");
let alphabet = new Array(26).fill(1).map((_, i) => String.fromCharCode(65 + i));
choices.forEach((choice) => {
let pos = parseInt(choice.id.split("-")[1]) - 1;
choice.innerText = alphabet[pos] + ". " + choice.innerText;
});
});
If its just for some questions, then you'll need to add it to each question individually, and replace
documentwith
this.questionContainer
If you want to use lower case then change 65 to 97
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
