Display Piped Text As List, Not Paragraph | XM Community
Skip to main content

Does anyone know how to have piped text display as a list instead of a paragraph separated by commas?

For example, piped text will display selected options such as: “Take my medication, Set a reminder, Talk to a friend, Other, make time to do it”

I would like it to display as:

Take my medication

Set a reminder

Talk to a friend

Other, make time to do it. 

 

Thank you!

 

Hi @MarissaD ,

Suppose you are getting the pipe text from Q1 and inserting it into Q2 (assuming it is a text/graphic question type). Follow the given steps.

STEP 1: Insert the below Javascript into your Q2. (Replace the below QID1 with your actual QID - from where you will be getting the choices)

 

Qualtrics.SurveyEngine.addOnload(function()
{
var selectedChoices = "${q://QID7/ChoiceGroup/SelectedChoices}"; 
var formattedList = selectedChoices.replace(/,\s*/g, '<br>');
jQuery("#formatted-list").html(formattedList);


});

STEP 2: Insert this HTML into Q2 question text (- HTML view section). 

<div id="formatted-list">Loading...</div>


It should work!


The above code works on my end! Also, TomG has some code here that will turn piped text into a bulleted list.


Leave a Reply