I have a survey and I want to show participants their responses for review before submitting. These are all multiple selection items. By default, the piped responses come in separated by a comma (selection1, selection2, selection3). I would like to instead put these each on a new line. They are all being brought in to a descriptive text element. I wrapped the descriptive text in a <span> with an id=ReviewWrapper and then added the JS below. Rather than replacing the commas, it is replacing the entire descriptive text with /,/g. I can't for the life of me figure out why. Relatively new to JS and this is one of my first attempts at implementing JS in Qualtrics. Any help is greatly appreciated.
> Qualtrics.SurveyEngine.addOnload(function()
> {
> var pipedText = $('ReviewWrapper');
> console.log(pipedText);
> pipedText.replace(new RegExp(",", 'g'), '/n');
> console.log(pipedText);
> });
Page 1 / 1
Change your replacement from:
`pipedText.replace(new RegExp(",", 'g'), '/n');`
To:
`pipedText.replace(/,/g, '\\n');`
`pipedText.replace(new RegExp(",", 'g'), '/n');`
To:
`pipedText.replace(/,/g, '\\n');`
Um... That did not work for me... Your answer is still making only "/,/g" show up...
I am trying to do this (list with breaks instead of commas) in the e-mail trigger. I have replaced the source code to look like:
<div class="CommaReplacement">${q://QID7/ChoiceGroup/SelectedChoices}</div>
and have updated the JS to the question (according to the code that was provided), however, I still get the long list across the page, separated by commas. HELP!
<div class="CommaReplacement">${q://QID7/ChoiceGroup/SelectedChoices}</div>
and have updated the JS to the question (according to the code that was provided), however, I still get the long list across the page, separated by commas. HELP!
Correction: This is what I have for the particular question:
<div class="CommaReplacement">${q://QID7/ChoiceGroup/SelectedChoices}</div>
<div class="CommaReplacement">${q://QID7/ChoiceGroup/SelectedChoices}</div>
> @rhonnied1 said:
> Correction: This is what I have for the particular question:
> <div class="CommaReplacement">${q://QID7/ChoiceGroup/SelectedChoices}</div>
> Correction: This is what I have for the particular question:
> <div class="CommaReplacement">${q://QID7/ChoiceGroup/SelectedChoices}</div>
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.