Check out the LimeSurvey source code on GitHub!

if statements and answers/tokens

More
3 years 8 months ago #96052 by Karel_UTwente
Is it possible to display a token attribute or previous question from within an if statement?

My syntax is something along the lines of
{if(contact == 'Y', 'Text {municipality} text', 'text')}

I can't make double if statements for both pieces of text, since one option includes the answer, and the other doesnt, so I need some way to include the answer itself into the if statement. The above syntax simply displays {municipality} in plain text (as I rather expected).

I've also tried to 'break out' of the EM by closing and reopening the brackets like below, but the EM stops looking for brackets once it's in the if statement, and simply displays the brackets (which kindof makes sense).
{if(contact == 'Y', 'Text} {municipality} {text', 'text')}

This text is supposed to show up in a group description, so avoiding the whole issue by simply creating a group for each case is something I'ld rather avoid.

Is this possible? Am I missing something obvious?

FYI: We're using Version 1.92+ Build 120319 which I know is slightly(?) outdated.

Please Log in to join the conversation.

More
3 years 8 months ago #96053 by Karel_UTwente
After having some coffee and a cookie, I realised what I was doing trying to break out of the EM was rediculous, and put my limited javascript/php experience to work.
{if(contact == 'Y', 'Text ' + municipality + ' text', 'text')}

Does exactly what I want it to.

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form