Welcome to the LimeSurvey Community Forum

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

Setting a hidden radio button based on previous question

  • paulfiner
  • paulfiner's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
4 years 2 months ago #193937 by paulfiner
I'm trying to populate a radio button (hidSEG) question based on answers to a previous radio button (S4)
I have an equation question with the following code:
{hidSEG=if(S4.NAOK==4 OR S4.NAOK==5 OR S4.NAOK==6 OR S4.NAOK==8,1,2)}

This works in that I see the code 1 or 2 appearing in the equation question but the hidSEG question doesn't change at all.
I've been through several posts from the forum trying to do the same thing but I can't get it to work.

I'm using Limesurvey v2.73.0
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 2 months ago #193938 by holch
Can you upload a small sample of your survey with just the relevant questions.

But the equation looks wrong to me.

I think you need to do something like {if(S4.NAOK==4 OR 5 OR 6 OR 8, hidSEG=1, hidSEG=2)}

Not tested, not sure it works, but I think the structure must be like this rather different.

Let's see if Tpartner, Joffm or Denis can come up with a working example.

If you send the sample survey, I might play around a bit when I find the time. But I am pretty sure the equation is wrong.

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • paulfiner
  • paulfiner's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
4 years 2 months ago #193941 by paulfiner
Thanks Holch for looking at this. I changed the equation around to match your suggestion but it still doesn't work.
Attached is a small sample with the relevant questions.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 2 months ago #193948 by tpartner
The expression in your first post is the correct format and does work except that in your equation question it is wrapped in a <p> element so it would be good to remove that.

You must understand that the Expression Manager assignment operator only manipulates questions on page load and submit so you will not see the value of "hidSEG" dynamically change as you change "S4".

See the attached sample survey:

File Attachment:

File Name: limesurvey...3226.lss
File Size:20 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: holch
The topic has been locked.
  • paulfiner
  • paulfiner's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
4 years 2 months ago #193949 by paulfiner
Hi Tony,

Thanks for looking at this - I didn't realise that the hidSEG wouldn't be dynamically changed.

Cheers,
Paul
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
4 years 2 months ago #193955 by holch

The expression in your first post is the correct format and does work except that in your equation question it is wrapped in a <p> element so it would be good to remove that.

Thank you for clarifying, Tony!

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose