Welcome to the LimeSurvey Community Forum

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

Have HTML in an expression? Stop LS from regenerating code?

  • rcha88AA
  • rcha88AA's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 11 months ago - 4 years 11 months ago #183458 by rcha88AA
Hi, in the end message area of my survey I want some information shown from the responses received.
For example, if a user says they only sleep for 5 hours, I want to show a sentence about the importance sleep, and give a URL with sleep advice.

Showing text based on a responce is no problem:
Code:
{if(AB06 == "Y", "You sleep enough, good!", "Try to sleep more, 8 hours of sleep is very important for the human body.")}

But if I want to show a URL with the text, that is causing problems.
Inserting a link in the gui/wysiwyg editor gives errors when displaying, I assume because the html link uses double quotes and the limesurvey expression also uses double quotes.
Code:
{if(AB06 == "Y", "You sleep enough, good!", "Try to sleep more, 8 hours of sleep is very important for the human body - <a href="http://example.com/">http://example.com/</a>")}

If I go into the source editor, and escape the html link double quotes with a '\', or simply replace the double quotes with single quotes, it works great.
But upon going back to the editor again saving (not even making any changes), limesurvey 'fixes' the source removing my edits, and the link doesn't work anymore.

Is there anyway to fix this, so that I can have html in an expression without LimeSurvey "interfering" with the source?

Thank you very much :)
Last edit: 4 years 11 months ago by rcha88AA.
The topic has been locked.
  • elissa
  • elissa's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 11 months ago #183468 by elissa
Hi, I tried it with reversed quotation marks and it works:
Code:
{if(AB06 == 'Y', 'You sleep enough, good!', 'Try to sleep more, 8 hours of sleep is very important for the human body - <a href="http://example.com/">http://example.com/</a>')}

Cheers

Elzbieta Lesinska
LS voluntary Polish translator and supervisor
The following user(s) said Thank You: DenisChenu, tpartner, rcha88AA
The topic has been locked.
  • rcha88AA
  • rcha88AA's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 11 months ago #183476 by rcha88AA
elissa that works perfectly! I didn't test/think that we could write expressions with single quotes. My mistake.

Thank you!
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose