Solved
How to change the separator for piped text
Here is one that I have solved, and will post a solution after the beta finishes out, but till then would love to see everyone's solutions!
When using piped text, how can I change commas (or some other arbitrary character / value) to something else (line breaks, dashes, other words, etc.).
As I said, I have a solution, but I would love to see what you all come up with in the mean time.
Best answer by AnthonyR
@MartyK
The most common use case I have seen is people wanting to display a list of selected options in a unique way. For instance instead of Dog, Cat, Bird, Fish; perhaps you want it to display as:
Dog
Cat
Bird
Fish
As for how to achieve this, first pip your text in to a div or span html tag with the class "CommaReplacement", for example:
`Your answers are: <div class='CommaReplacement'>${q://QID1/ChoiceGroup/SelectedChoices}</div>`
Then, add the following JavaScript to your questions JavaScript editor, updating the newDelimiter to your desired effect:
Qualtrics.SurveyEngine.addOnReady(function()
{
var textElements = this.questionContainer.select('.CommaReplacement');
var newDelimiter = "<br>"
for(var i = 0; i<textElements.length; i++){
var temp = textElements[i].innerHTML;
console.log(temp);
temp = temp.replace(new RegExp(", ", 'g'), newDelimiter);
console.log(temp);
textElements[i].innerHTML = temp;
}
});
This will also work with multiple "CommaReplacement" tags in the same question. However it will only affect the current question.
I have attached a QSF demo for this.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
