- Posts: 22
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Changing colors of INSERTANS values dynamically
- Gensz78
- Topic Author
- Offline
- Junior Member
Less
More
6 years 5 months ago - 6 years 5 months ago #160789
by Gensz78
Changing colors of INSERTANS values dynamically was created 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
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: 6 years 5 months ago by Gensz78. Reason: Removed unnecessary attachment
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12921
- Thank you received: 3976
6 years 5 months ago - 6 years 5 months ago #160791
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on 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
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 5 months ago by Joffm.
The topic has been locked.
- Gensz78
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 22
- Thank you received: 0
6 years 5 months ago #160792
by Gensz78
Replied by Gensz78 on topic Changing colors of INSERTANS values dynamically
Thanks for your help. It doesn't seem to work unfortunately.
Gen
Gen
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12921
- Thank you received: 3976
6 years 5 months ago - 6 years 5 months ago #160793
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on 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
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
Attachments:
Last edit: 6 years 5 months ago by Joffm.
The topic has been locked.
- Gensz78
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 22
- Thank you received: 0
6 years 5 months ago #160824
by Gensz78
Replied by Gensz78 on 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
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12921
- Thank you received: 3976
6 years 5 months ago #160825
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Changing colors of INSERTANS values dynamically
Hello, Gen,
see attached example.
Regards
Joffm
see attached example.
Regards
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
The following user(s) said Thank You: Gensz78
The topic has been locked.
- Gensz78
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 22
- Thank you received: 0
6 years 5 months ago #160826
by Gensz78
Replied by Gensz78 on 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
Gen
The topic has been locked.