Changing colors of INSERTANS values dynamically

More
3 weeks 5 days ago - 3 weeks 5 days ago #160789 by Gensz78
Gensz78 created the topic: Changing colors of INSERTANS values dynamically
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
Attachments:
Last Edit: 3 weeks 5 days ago by Gensz78. Reason: Removed unnecessary attachment

Please Log in to join the conversation.

More
3 weeks 5 days ago - 3 weeks 5 days ago #160791 by Joffm
Joffm replied the topic: Changing colors of INSERTANS values dynamically
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
Last Edit: 3 weeks 5 days ago by Joffm.

Please Log in to join the conversation.

More
3 weeks 5 days ago #160792 by Gensz78
Gensz78 replied the topic: Changing colors of INSERTANS values dynamically
Thanks for your help. It doesn't seem to work unfortunately.

Gen

Please Log in to join the conversation.

More
3 weeks 5 days ago - 3 weeks 5 days ago #160793 by Joffm
Joffm replied the topic: Changing colors of INSERTANS values dynamically
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
Attachments:
Last Edit: 3 weeks 5 days ago by Joffm.
The following user(s) said Thank You: LouisGac

Please Log in to join the conversation.

More
3 weeks 2 days ago #160824 by Gensz78
Gensz78 replied the topic: Changing colors of INSERTANS values dynamically
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

Please Log in to join the conversation.

More
3 weeks 2 days ago #160825 by Joffm
Joffm replied the topic: Changing colors of INSERTANS values dynamically
Hello, Gen,

see attached example.

File Attachment:

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


Regards
Joffm
Attachments:
The following user(s) said Thank You: Gensz78

Please Log in to join the conversation.

More
3 weeks 2 days ago #160826 by Gensz78
Gensz78 replied the topic: Changing colors of INSERTANS values dynamically
Thank you so much! I wasn't putting the code in the right place at all! It works flawlessly now!

Gen

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!