Welcome to the LimeSurvey Community Forum

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

Changing colors of INSERTANS values dynamically

  • Gensz78
  • Gensz78's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 11 months ago - 6 years 11 months ago #160789 by Gensz78
Hi all!

Is it possible to change the colors of INSERTANS values dynamically? Let me explain. In a survey I'm setting up, we're asking participants to rate items according to their Low, Medium or High importance. We then show them a summary table with their ratings using INSERTANS. See:



In this table, would it be possible to have the "Low" value red, the "Medium" value yellow, and the "High" value green?

Please note that I'm using version 2.65.1+170522 and don't have access to the template. Javascript is enabled though.

The survey structure is attached.

Thank you!

Gen
Last edit: 6 years 11 months ago by Gensz78. Reason: Removed unnecessary attachment
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 11 months ago - 6 years 11 months ago #160791 by Joffm
Just seeing your table, I think of using a <span>tag and setting the color by expression:

if(rating=="low","<span style='color:red'>",if(rating=="medium","<span style='color:yellow'>","<span style='color:green'>"))

or something like that.

Regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 6 years 11 months ago by Joffm.
The topic has been locked.
  • Gensz78
  • Gensz78's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 11 months ago #160792 by Gensz78
Thanks for your help. It doesn't seem to work unfortunately.

Gen
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 11 months ago - 6 years 11 months ago #160793 by Joffm
Hello, Gen,
with
Item 1: {if(Q1_SQ001==1,"<span style='color:red'>low</span>",if(Q1_SQ001==2,"<span style='color:yellow''>medium</span>","<span style='color:green'>high</span>"))}

Item 2: {if...
...

I get:


You see the double and single quotes?
Beware: the editor always changes single quotes to double.
So save and never touch.

Best regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 6 years 11 months ago by Joffm.
The topic has been locked.
  • Gensz78
  • Gensz78's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 11 months ago #160824 by Gensz78
Hi!

Pardon me, I'm still learning all these things! I think I'm not putting the code at the right place. Where exactly should I be putting it in relation to the rest of the code? Should I still use INSERTANS?

Thanks!

Gen
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 11 months ago #160825 by Joffm
Hello, Gen,

see attached example.

File Attachment:

File Name: limesurvey...1-20.lss
File Size:17 KB


Regards
Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: Gensz78
The topic has been locked.
  • Gensz78
  • Gensz78's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
6 years 11 months ago #160826 by Gensz78
Thank you so much! I wasn't putting the code in the right place at all! It works flawlessly now!

Gen
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose