Welcome to the LimeSurvey Community Forum

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

Using insertans within if commands

  • joebloggs1987
  • joebloggs1987's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 8 months ago #157650 by joebloggs1987
Using insertans within if commands was created by joebloggs1987
I am just wondering how to display an answer by using an if command.

E.g....
if(a == 1, "insertans", "")

Is there a way of doing this in Limesurvey?

Thanks.
The topic has been locked.
  • Joffm
  • Joffm's Avatar
  • Away
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 8 months ago - 6 years 8 months ago #157652 by Joffm
Replied by Joffm on topic Using insertans within if commands
Of course:

Without knowing exactly, what "a==1" is, well, just any comparison.
Something like: {if(a==1,Q01_SQ001.NAOK,"alternative text")}

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 6 years 8 months ago by Joffm.
The following user(s) said Thank You: mandroul
The topic has been locked.
More
4 years 9 months ago #186139 by mandroul
Replied by mandroul on topic Using insertans within if commands
Hi Joffm,

I'm trying to do the same but when I'm using the following statement in my question:

{if(Q4.NAOK == 'A1','alternative text')}

I get syntax errors:



Would appreciate any help as I can't find any troubleshooting on the manual
The topic has been locked.
More
4 years 9 months ago #186156 by jelo
Replied by jelo on topic Using insertans within if commands
The issue is in the Question Q4 itself. The variable Q4 contains more data than needed.
What is Q4. If it is a Equation question it might contain HTML code somewhere, which pollutes the variable Q4.

The meaning of the word "stable" for users
www.limesurvey.org/forum/development/117...ord-stable-for-users
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 9 months ago - 4 years 9 months ago #186159 by tpartner
Replied by tpartner on topic Using insertans within if commands
Your IF statement is incomplete. You need to include both the result if true and the result if untrue.

Code:
{if(Q4.NAOK == 'A1', 'Result if true', 'Result if untrue')}

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 4 years 9 months ago by tpartner.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 9 months ago #186162 by DenisChenu
Replied by DenisChenu on topic Using insertans within if commands

tpartner wrote: Your IF statement is incomplete. You need to include both the result if true and the result if untrue.

Not since 3.0.2 :)
github.com/LimeSurvey/LimeSurvey/commit/...9b8a12bc55cd33b46a1e


Else : i think there are a bad copy/paste of code looking at www.limesurvey.org/media/kunena/attachments/195537/Capture.PNG screenshot.

I my opinion : you must check HTML source of question

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.
The topic has been locked.
More
4 years 9 months ago - 4 years 9 months ago #186209 by mandroul
Replied by mandroul on topic Using insertans within if commands
Thank you all, you've been very helpful.

I can confirm that the field of the untrue case does not need to be completed if not necessary.

Issue resolved after checking the HTML source.

It seems that somehow some options/tags were added on the background in the HTML source after pasting from word and changing fonts. Just removing the extra added options/tags resolved the issue.

Couldn't reproduce the issue for potentially filling a bug report.
Last edit: 4 years 9 months ago by mandroul.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose