- Posts: 8
- Thank you received: 2
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
conditional show for images
- skywalker23
- Topic Author
- Offline
- New Member
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.
- Joffm
- Offline
- LimeSurvey Community Team
- Posts: 12880
- Thank you received: 3964
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
- tpartner
- Offline
- LimeSurvey Community Team
- Posts: 10098
- Thank you received: 3589
<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.
- skywalker23
- Topic Author
- Offline
- New Member
- Posts: 8
- Thank you received: 2
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' />")}
- skywalker23
- Topic Author
- Offline
- New Member
- Posts: 8
- Thank you received: 2
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
but seems it does NOT work properly,{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' />"))}
is there something wrong with the syntax?
Thank you.
- Joffm
- Offline
- LimeSurvey Community Team
- Posts: 12880
- Thank you received: 3964
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
- Joffm
- Offline
- LimeSurvey Community Team
- Posts: 12880
- Thank you received: 3964
{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
- DenisChenu
- Offline
- LimeSurvey Community Team
- Posts: 13597
- Thank you received: 2487
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
- skywalker23
- Topic Author
- Offline
- New Member
- Posts: 8
- Thank you received: 2
thank you.