Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Conditionally display bullet points in list depending on value of URL parameters

  • syssecsurvey
  • syssecsurvey's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 7 months ago - 3 years 7 months ago #219545 by syssecsurvey
Hello,
My current survey uses URL parameters to populate a hidden question (multiple short texts) with information which of a set of conditions apply to the participant. Later I would like to present participants with a text display containing a list of the conditions that apply to the participant.

Like so:

URL: survey.domain.net/index.php?r=survey/ind...=y¶m2=n¶m3=y

The text display would need to look like this:

The following conditions apply to you:
  • Condition 1
  • Condition 3
Meaning that individual bullets are only shown when the corresponding URL parameter has a certain value (not necessarily an integer).

What would be the best way to do that?
Many thanks in advance!
Last edit: 3 years 7 months ago by syssecsurvey.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 7 months ago #219547 by Joffm
Like this?
 

The hidden "multiple short text" question is called Q0.
This shows
 

With this url.

www.myServer/lime/index.php/123123?lang=...Q0_4=y&Q0_5=n&Q0_6=n


And the "textdisplay" question?
Include an if-statement
Code:
<ul>
    {if(Q0_1=='y','<li>Condition 1</li>','')}
    {if(Q0_2=='y','<li>Condition 2</li>','')}
    {if(Q0_3=='y','<li>Condition 3</li>','')}
    {if(Q0_4=='y','<li>Condition 4</li>','')}
    {if(Q0_5=='y','<li>Condition 5</li>','')}
    {if(Q0_6=='y','<li>Condition 6</li>','')}
</ul>

Please, do not use the HTML-Editor (it will destroy everything becqause of the HTML-tags).
Use the plain text editor
 

 

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • syssecsurvey
  • syssecsurvey's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 7 months ago - 3 years 7 months ago #219549 by syssecsurvey
I think I got it to work as follows:

<ul>
    {if(param=='value','<li>Text</li>','')}
</ul>

Unfortunately, whenever I go back to that question to edit it, the auto-complete functionality for HTML tags wrecks the input into the question box and I end up with something like this:

<li>{if(param=='value','</li>
    <li>Text</li>
    <li>','')}

Is there any way to turn this off? Or a better way (with less annoying consequences) to achieve what I want to do?


Edit: Thanks Joffm for the detailed explanation, including how to avoid the mess with the HTML tags! Somehow your response didn't show up when I refreshed this thread before I posted my follow-up.

Edit 2: Unfortunately, when I change the editor to plaintext, any expressions added afterwards are no longer correctly interpreted as such. What could be done about that?
Edit 3: Got it, the problem was due to the displayed text containing an apostrophe, which accidentally terminated the first function parameter.
Last edit: 3 years 7 months ago by syssecsurvey.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose