Hi everyone,
I am trying to pipe in responses from a matrix question into the question text of the following question. For example, I have a list of topics to rate from 0-10. I would like to pipe the response in the next question "you noted some dissatisfaction with [answer <7 here]. See below the matrix. When I pipe in ${q://QID40/ChoiceGroup/SelectedChoicesForAnswer/1}, ${q://QID40/ChoiceGroup/SelectedChoicesForAnswer/2} etc... I see this in the second picture.
Do you know how to remove those extra commas at the end? this would be if a rating is greater than 7.
Remove commas from blank selection
If you can break the block between these two question, then using branch logic you can check if count of scale point 0 selection is greater than or equal to 1 then update an embedded data(SelOption) with the selected choice Answer 1 text along with that embedded data comma separated as show below: Similarly do this for all scale points up to 7.
OR
Using JS: In the question text HTML insert this :
you noted some dissatisfaction with
Now in the JS(onReady function) of question Q34, check:
var s ="";
if("${q://QID40/ChoiceGroup/SelectedChoicesForAnswer/1}"!=""){
s = s+", "+"${q://QID40/ChoiceGroup/SelectedChoicesForAnswer/1}";
}
if("${q://QID40/ChoiceGroup/SelectedChoicesForAnswer/2}"!=""){
s = s+", "+"${q://QID40/ChoiceGroup/SelectedChoicesForAnswer/2}";
}
Similarly do the above if for all scale points and at the end set s as text of span class selOption
jQuery(".selOption").text(s);
Thank you! I went with the JS solution.
I now have a block of text though. It would be much easier to read with line breaks. Or even a bullet in front of each line. Do you know how to include a line break in the list?
Here's what I've tried so far, just on the line break:
Replacing the ", " with: "
", "
, "\\n", "\\r", "\\r\\n"
ex: }
if("${q://QID40/ChoiceGroup/SelectedChoicesForAnswer/2}"!=""){
s = s+"\\r\\n"+"${q://QID40/ChoiceGroup/SelectedChoicesForAnswer/2}";
}
Or is this an issue with the function in the question text?
If you do not have any "," in your statements, then after all the ifs statement, just put below code:
s = s.replace(/,/g,"
")
jQuery(".selOption").text(s);
Thank you. I've added that code, just below the If statements . Here's what I'm getting now when I test the quesiton:
The line breaks are not being read correctly. Do you have any ideas on how to address this?
Here's the code now, it case that's helpful.
});
Qualtrics.SurveyEngine.addOnReady(function()
{
var s ="";
if("${q://QID40/ChoiceGroup/SelectedChoicesForAnswer/1}"!=""){
s = s+", "+"${q://QID40/ChoiceGroup/SelectedChoicesForAnswer/1}";
}
if("${q://QID40/ChoiceGroup/SelectedChoicesForAnswer/2}"!=""){
s = s+", "+"${q://QID40/ChoiceGroup/SelectedChoicesForAnswer/2}";
}
s = s.replace(/,/g,"
")
jQuery(".selOption").text(s);
});
Leave a Reply
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.