- Posts: 4
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
conditional images not working
- tranal
- Topic Author
- Offline
- New Member
Less
More
1 year 7 months ago - 1 year 7 months ago #232060
by tranal
conditional images not working was created by tranal
Please help us help you and fill where relevant:
Your LimeSurvey version: Version 5.3.31
Own server or LimeSurvey hosting: Limesurvey hosting
Survey theme/template: Inherti[fruity]
==================
I have tried for several hours to get this to work with no avail. I have consulted several threads previously, with considerable care to make my code identical with no errors (e.g., NOT double quotes in double quotes)
forums.limesurvey.org/forum/design-issue...ge-with-if-condition
forums.limesurvey.org/forum/can-i-do-thi...onal-show-for-images
forums.limesurvey.org/forum/can-i-do-thi...n-previous-responses
No matter what I do, it won't accept my IF logic, despite putting it into the source code. I keep getting an image popping up NO MATTER what I select. I have tried multiple iterations of referring to the question previous (e.g., changing the question name, using answers that are numeric only etc. etc.) Always it looks like this, with the IF statement showing up for some reason (see image attached):
My code is below:
{if(
(tt.NAOK=="t3"),
"<img src='/upload/surveys/998569/images/SampleLabelPlaceHolder2.png' />", "<img src='/upload/surveys/998569/images/units.jpg' />")
)
}
My survey is attached.
A more "complicated version" to be implemented is below as well:
{if(
(tt.NAOK=="t3"),
'<img src="/upload/surveys/998569/images/SampleLabelPlaceHolder.png" />',
if(
(tt.NAOK=="t2"),
'<img src="/upload/surveys/998569/images/SampleLabelPlaceHolder2.png" />', '<img src="/upload/surveys/998569/images/units.jpg" />')
)
}
Your LimeSurvey version: Version 5.3.31
Own server or LimeSurvey hosting: Limesurvey hosting
Survey theme/template: Inherti[fruity]
==================
I have tried for several hours to get this to work with no avail. I have consulted several threads previously, with considerable care to make my code identical with no errors (e.g., NOT double quotes in double quotes)
forums.limesurvey.org/forum/design-issue...ge-with-if-condition
forums.limesurvey.org/forum/can-i-do-thi...onal-show-for-images
forums.limesurvey.org/forum/can-i-do-thi...n-previous-responses
No matter what I do, it won't accept my IF logic, despite putting it into the source code. I keep getting an image popping up NO MATTER what I select. I have tried multiple iterations of referring to the question previous (e.g., changing the question name, using answers that are numeric only etc. etc.) Always it looks like this, with the IF statement showing up for some reason (see image attached):
My code is below:
{if(
(tt.NAOK=="t3"),
"<img src='/upload/surveys/998569/images/SampleLabelPlaceHolder2.png' />", "<img src='/upload/surveys/998569/images/units.jpg' />")
)
}
My survey is attached.
A more "complicated version" to be implemented is below as well:
{if(
(tt.NAOK=="t3"),
'<img src="/upload/surveys/998569/images/SampleLabelPlaceHolder.png" />',
if(
(tt.NAOK=="t2"),
'<img src="/upload/surveys/998569/images/SampleLabelPlaceHolder2.png" />', '<img src="/upload/surveys/998569/images/units.jpg" />')
)
}
Last edit: 1 year 7 months ago by tranal.
Please Log in to join the conversation.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13055
- Thank you received: 4021
1 year 7 months ago #232062
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic conditional images not working
Having imported your survey I see two things
1. There are nested quotes.
Obviously you used the Iline HTML editor. This type of editor has a strange way to handle quotes.
Better you use the source code editor.
Select the editor in your personal settings
2. Remove one closing bracket.
Joffm
1. There are nested quotes.
Obviously you used the Iline HTML editor. This type of editor has a strange way to handle quotes.
Better you use the source code editor.
Select the editor in your personal settings
2. Remove one closing bracket.
Code:
{if(tt.NAOK=="t3", '<img src="/limesurvey/upload/surveys/998569/images/SampleLabelPlaceHolder2.png" />', '')}
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: tranal
Please Log in to join the conversation.