Thanks, @Sachin Nandikol! That worked perfectly.
@Lauren_Hitchcock, No offense, but it seems a bit kludgy. I think this is cleaner, supports allow text on any choices, and doesn’t require any additional html or piped fields: Qualtrics.SurveyEngine.addOnPageSubmit(function() { var selected = []; jQuery("#"+this.questionId+" [choiceid]:checked").each(function() { var item = jQuery(this).closest(".Selection"); var label = item.find(".LabelWrapper label>span").html(); if(item.find(".InputText").length>0) label += " "+item.find(".InputText").val(); selected.push("<li>"+label+"</li>"); }); Qualtrics.SurveyEngine.setEmbeddedData("choiceText","<ul>"+selected.join("")+"</ul>");}); Thanks so much, Tom! And not even a little bit of offense taken. I knew there was probably a better way to do it. Thanks again!
UPDATE:I think I might have figured it out. Here’s my new code with a slice added in to remove the extra characters in my HTML code. Would love it if somebody could look at it and let me know if I’ve done anything wrong or if it could be done better (because I sure don’t know lol).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 + "</li><li>"; }choiceText = choiceComma.replace(/,\s*$/, "");choiceText = choiceText.slice (0, -9);Qualtrics.SurveyEngine.setEmbeddedData("choiceText",choiceText);});And then I have this HTML in my email:<ul> <li>${e://Field/choiceText} ${q://QID8/ChoiceTextEntryValue/8}</li></ul>It seems to work! 🤞
@TomG - I’d like to tweak my code a little bit more. My multi-select question has an option to select “other” and enter a text response for that selection. Can I include that text entry in this embedded data field if “other” is selected? Like, instead of doing a list of the Selected Choices, change the code to do a list of the “Selected Choices - Entered Text” so that it includes everything? I tried just doing it like this in the email:${e://Field/choiceText}${q://QID8/ChoiceTextEntryValue/8}...but it creates an extra line break at the end when “other” isn’t selected.I hope this makes sense.
Thanks, Tom! Follow-up question: my multi-select question has an option to select “other” and allows text entry for that selection. Can I include that text entry in this embedded data field if “other” is selected?
Forgive my ignorance (because I know next to nothing about javascript), but I can't get this to work, and I'm pretty sure it's because I'm doing it wrong (because I know next to nothing about javascript ha!). SO...I've added this to the survey header: But when I add to a text input field the jQuery bit that TomG posted above, it doesn't do anything. I'm pretty sure i'm missing some code that it's assumed I should know...but...since *I know next to nothing about javascript*, I don't know what code is missing in order to "use JS to attach it to a text input field". Sorry! I just don't know what I'm doing and could use a little bit of hand holding. 🤦♀️
Already have an account? Login
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.
Sorry, we're still checking this file's contents to make sure it's safe to download. Please try again in a few minutes.
Sorry, our virus scanner detected that this file isn't safe to download.