I’ve searched the forums, but I haven’t quite found what I need, and I’m not experienced enough with Javascript to figure it out myself. What I want to do is take the response from a multi-select multiple choice question, and pipe the answer into an email that lives in the workflow. When I simply pipe it in as is, the items are all listed in a long string separated with commas. What I’d prefer, is to have them separated by HTML line breaks <br> so that they’ll display nicely in the email.
Here’s the code I currently have in the javascript setting of my multi-select question:
Qualtrics.SurveyEngine.addOnPageSubmit(function()
{
var selChoice = this.getSelectedChoices();
var choiceRef = "";
var choiceComma = "";
var choiceText = "";
for (let i = 0; i < selChoice.length; i++) {
choiceRef = "#" + this.questionId + "-" + selChoice i] + "-label > span";
choiceComma += document.querySelector(choiceRef).innerHTML + ", ";
}
choiceText = choiceComma.replace(/,\s*$/, "");
Qualtrics.SurveyEngine.setEmbeddedData("choiceText",choiceText);
});
It gives me my embedded list, but I can’t figure out how to replace the commas with <br>.