Editing Carry-Forward Multiple-Choice Answer Options | XM Community
Question

Editing Carry-Forward Multiple-Choice Answer Options

  • 15 June 2021
  • 2 replies
  • 38 views

Hi all,
I was recently working on a survey where I wanted to carry-forward the answer options for a multiple choice question. Basically, we asked respondents which political candidate they preferred ( 1. Candidate A, 2. Candidate B, 3. Candidate C, etc). The answer options were randomized. Then if the respondent didn't choose a candidate, we wanted a follow up question asking which one they leaned towards. So the answer options would be 1. LEAN Candidate Q, 2. LEAN Candidate B, 3. LEAN Candidate C. The display logic was fairly easy, however I wanted to use the carry-forward function, so that I could present the answer options in the SAME randomized order as the first question. However, with this function there is no way to edit the answer options to add that word "lean." I've heard from a couple folks this is possible with java script, however I haven't been able to figure out what that script would be/how to use it. Does anyone know how to achieve this?
Any ideas are much appreciated! Thank you!


2 replies

Userlevel 7
Badge +21

document.querySelectorAll("li.Selection").forEach((choice) => {
    let dec = choice.querySelectorAll("*:not(.clear)");
    dec[dec.length - 1].innerText = "LEAN " + dec[dec.length - 1].innerText;
});

Hi! Thank you very much for the response Ahmed! Unfortunately, this didn't seem to work quite correctly for me. As I stated above, I was hoping to find a java script that would allow me to use the carry-forward function to present answer options in same randomized order as the previous question, however I wanted to be able to edit the answer options to add the word "LEAN" before (we're hoping to use this for political surveys to ask respondents which candidate they lean towards). I also set up display logic so that the second question would ONLY show up if no answer was selected for the first. I copy/pasted the Java Script into a test survey in Qualtrics with no issues. However, when I didn't select an answer option on the first question, no answer options popped up on my second question. If I did select an answer for the first question (EX. Answer A) only that answer option would show up for the following question (Ex. Answer A). I have very little experience with java script, so I'm not sure why this is happening.
I know this is getting a bit complicated, but if anyone has ideas on how to resolve this issue, they would be much appreciated! It seems like the java script isn't quite right, but I'm not sure what needs to change.
Thank you for any help! :)

Leave a Reply