Welcome to the LimeSurvey Community Forum

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

Enter images to a question depending on an answer

  • Fran1991
  • Fran1991's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
1 month 4 weeks ago #257614 by Fran1991
Please help us help you and fill where relevant:
Your LimeSurvey version: [see right hand bottom of your LimeSurvey admin screen]
Own server or LimeSurvey hosting:
Survey theme/template:
==================
(Write here your question/remark)
Hello everyone,

Is there a way to insert images depending on the answer to a radio question?


What I did is have a radio question

P01. Which soft drink do you like the most?

1. Cocacola
2. Pepsi
3. Red Cola
4. Aurrera
5. Chedraui.

So my next question is based on this answer but I have to show the image of the soda.

I tried to do this.

{P01.NAOK==1, "<img src=" www.cmmkt.com/BUCMMKTant/images/Cocacola.jpg ",""),if(P01.NAOK==2, " www.cmmkt.com/BUCMMKTant/images/Pepsi.jpg ","")))}

But this makes me wrong.

Does anyone know how to correct this?

Thank you

Please Log in to join the conversation.

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 month 4 weeks ago #257628 by DenisChenu
Replied by DenisChenu on topic Enter images to a question depending on an answer
If you use " inside string, you must use ' to wrap string. If you use ' inside string you must use " ti wrap string
Code:
{P01.NAOK==1, '<img src="https://www.example.com/BUCMMKTant/images/Cocacola.jpg">','')}{if(P01.NAOK==2,<img src="https://www.example.com/BUCMMKTant/images/Pepsi.jpg">','')}

A solution i like : name yourt image with the code of reponse and
Code:
<img src="https://www.example.com/BUCMMKTant/images/choice{P01.NAOK}.jpg">

really more easy.

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.

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose