Welcome to the LimeSurvey Community Forum

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

conditional show for images

  • skywalker23
  • skywalker23's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 11 months ago #213089 by skywalker23
conditional show for images was created by skywalker23
Hello guys, Good day.

i'm a newbie in LS. i'm developing a survey that need to show some kind of images with certain criteria.

already search in the forum and tried below type of command :

{if(1,"<img src='/upload/surveys/856746/images/A.jpeg' />","<img src='/upload/surveys/856746/images/B.jpeg' />")}


but it DOES NOT work :(
i'm writing it in the question type : "Text Display - type : X" (my LS version : 4.2.2)

could you help to provide the correct way? 

thank you in advanced.
 
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 11 months ago #213101 by Joffm
Replied by Joffm on topic conditional show for images
WHAT does not work?
Do you see an image?
Is this really what you entered?
I should say, you always see image "A.jpg". (condition is always TRUE)

So you should provide these relevant questions (condition question and this dependent image question) as lss export.

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
3 years 11 months ago #213112 by tpartner
Replied by tpartner on topic conditional show for images
Try this using simplified Expression Manager:

Code:
<img src="/upload/surveys/856746/images/{if(1, 'A', 'B')}.jpeg" />

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: skywalker23
The topic has been locked.
  • skywalker23
  • skywalker23's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 11 months ago - 3 years 11 months ago #213157 by skywalker23
Replied by skywalker23 on topic conditional show for images
hello All,

thank you for your quick responses.

turns-out i need to put the comment by switching to 'toggle source mode'. now it's working.

previously i put it in design/text area.it's newbie's problem ;)

{if(G01Q13.NAOK==5,"<img src='/upload/surveys/115564//Red.jpg' />","<img src='/upload/surveys/115564//Yellow.jpg' />")}

Last edit: 3 years 11 months ago by skywalker23.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
  • skywalker23
  • skywalker23's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 11 months ago #213158 by skywalker23
Replied by skywalker23 on topic conditional show for images
Hi All,

but when i tried to combine to command to show image based on criteria like this :
  • IF sum of answers == 0, then "Green.jpg" shown
  • IF sum of answers >=5, then "Red.jpg" shown
  • ELSE (sum of answers >=1 and <=4), then 'Yellow.jpg' shown 
by writing to below full syntax : 

{if(sum(G01Q09.valueNAOK,G01Q10.valueNAOK,G01Q11.valueNAOK,G01Q12.valueNAOK,G01Q13.valueNAOK,G01Q14.valueNAOK)==0,"<img src='/upload/surveys/877365//Green.jpg' />,if(sum(G01Q09.valueNAOK,G01Q10.valueNAOK,G01Q11.valueNAOK,G01Q12.valueNAOK,G01Q13.valueNAOK,G01Q14.valueNAOK)>=5,"<img src='/upload/surveys/877365//Red.jpg' />","<img src='/upload/surveys/877365//Yellow.jpg' />"))}

but seems it does NOT work properly,

is there something wrong with the syntax?

Thank you.

 
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 11 months ago #213160 by Joffm
Replied by Joffm on topic conditional show for images
Hi,
1. there are double quotes missing after the first <img>. Maybe it only is a typo.

2. A more logic order of the IF.
{if(sum((G01Q09.valueNAOK,G01Q10.valueNAOK,G01Q11.valueNAOK,...)==0,"<img src='/upload/surveys/877365//Green.jpg' />",  if(sum((G01Q09.valueNAOK,G01Q10.valueNAOK,G01Q11.valueNAOK,...)<5,"<img src='/upload/surveys/877365//Yellow.jpg' />","<img src='/upload/surveys/877365//Red.jpg' />"))}

And you really use assessment values?

And again: What means " it does NOT work properly,"?
No image displayed at all?
An image displayed, but the wrong one?
Or?
Joffm

 

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 11 months ago #213164 by Joffm
Replied by Joffm on topic conditional show for images
Small test.

{if(sum(Q1a.valueNAOK,Q1b.valueNAOK,Q1c.valueNAOK)==0,"<img src=" /lime3/upload/surveys/761949/images/Hamburg-Ballett_16.jpg" />" ,if(sum(Q1a.valueNAOK,Q1b.valueNAOK,Q1c.valueNAOK) lt 5,"<img src="/lime3/upload/surveys/761949/images/Hamburg-Ballett_10.jpg" />" ,"<img src="/lime3/upload/surveys/761949/images/Hamburg-Ballett_3.jpg" />"))}


No issue.
   

 





Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: DenisChenu, skywalker23
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
3 years 11 months ago #213176 by DenisChenu
Replied by DenisChenu on topic conditional show for images
\o/ @ Joffm our LimeSurvey hero !

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.
  • skywalker23
  • skywalker23's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 11 months ago #213238 by skywalker23
Replied by skywalker23 on topic conditional show for images
awesome! it's working now. you are the man, @Joffm !

thank you.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose