Welcome to the LimeSurvey Community Forum

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

HTML in expression manager

  • fmacho
  • fmacho's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 3 months ago - 4 years 3 months ago #211553 by fmacho
HTML in expression manager was created by fmacho
Hi, I try to customize Wellcome message based on token attribute. For example:

{if((TOKEN:ATTRIBUTE_5 == 19921), "<div>MBA</div>","<div>OTRO</div>")}

This works fine.

The problem is when use quotes, for example for class attribute on div

{if((TOKEN:ATTRIBUTE_5 == 19921), "<div class="bla">MBA</div>","<div class="bla">OTRO</div>")}

I try to simple quotes:

{if((TOKEN:ATTRIBUTE_5 == 19921), '<div class="bla">MBA</div>','<div class="bla">OTRO</div>')}
or
Scaping quotes
{if((TOKEN:ATTRIBUTE_5 == 19921), "<div class=\"bla\">MBA</div>','<div class=\"bla\">OTRO</div>")}
or using htmlspecialchars
{if((TOKEN:ATTRIBUTE_5 == 19921), htmlspecialchars('<div class="bla">MBA</div>'),htmlspecialchars('<div class="bla">OTRO</div>'))}

What is the correct for to add full html to expresion manager function? This options not work!
 
Last edit: 4 years 3 months ago by fmacho.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 months ago #211560 by Joffm
Replied by Joffm on topic HTML in expression manager
Hm,
I used this
{if(TOKEN:ATTRIBUTE_1 == 1234, '<div class="bla">MBA</div>','<div class="bla">OTRO</div>')}

and it works

 

 

Joffm

Tested in 3.25.7

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • fmacho
  • fmacho's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
4 years 3 months ago - 4 years 3 months ago #211567 by fmacho
Replied by fmacho on topic HTML in expression manager
Can you try:
{if(TOKEN:ATTRIBUTE_1 == 1234, '<div style="background-color:#dd2559; ">MBA</div>','<div style="background-color:#dd2559; ">OTRO</div>')}
[img


Lime version Version 3.25.0+201117
Last edit: 4 years 3 months ago by fmacho.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 months ago #211573 by Joffm
Replied by Joffm on topic HTML in expression manager
I added "color:white" that you see better.
 

The rule is: "Enter it and never touch it again"

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 3 months ago #211625 by tpartner
Replied by tpartner on topic HTML in expression manager

The rule is: "Enter it and never touch it again"

Or use the plain-text editor only.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
4 years 3 months ago #211648 by DenisChenu
Replied by DenisChenu on topic HTML in expression manager

tpartner wrote:

The rule is: "Enter it and never touch it again"

Or use the plain-text editor only.

Personnaly : i's for a Popup editor by default (or «HTML editor on demand» (this popup is so old school …))

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
More
4 years 3 months ago #211651 by fernandomacho
Replied by fernandomacho on topic HTML in expression manager
Hi I finally found the solution.

The problem is the editor when it is not maximized.  In this case the editor adds CR after char ' and this breaks the page.
If I maximize the editor and write, for example:

{if(TOKEN:ATTRIBUTE_1 == "MBA", '<span style="background-color: rgb(221, 37, 89);">MBA</span>','<span style="background-color: rgb(221, 37, 89);">NO MBA</span><br />')}

it works fine, but if I edit in normal mode and save the field, then it is stored in the data base as:
{if(TOKEN:ATTRIBUTE_1 == "MBA", '<span style="background-color: rgb(221, 37, 89);">MBA</span>
','
<span style="background-color: rgb(221, 37, 89);">NO MBA</span><br />
')}

I discovered this problem watching in the table lime_survey_languagesettings.
Thank you everybody for your help.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose