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

Display Piped Text As List, Not Paragraph

  • August 18, 2023
  • 2 replies
  • 225 views

Forum|alt.badge.img

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!

 

2 replies

Forum|alt.badge.img+21
  • QPN Level 5 ●●●●●
  • 306 replies
  • August 25, 2023

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!


Tom_1842
Level 8 ●●●●●●●●
Forum|alt.badge.img+28
  • Level 8 ●●●●●●●●
  • 909 replies
  • August 25, 2023

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