Welcome to the LimeSurvey Community Forum

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

Prefilling answers to a single choice

  • Matadeleo
  • Matadeleo's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
7 years 3 weeks ago #159405 by Matadeleo
Prefilling answers to a single choice was created by Matadeleo
Hi, I'm trying to prefill a single choice question based on a numeric response. See below.


Q2. How old are you? (Numeric)

Q2Equation: {Q2Quota=if(Q2<=39 AND Q2>=18, 1, if(Q2<=49 AND Q2>=40, 2, if(Q2<=99 AND Q2>=50, 3, "")))}

Q2Quota: Contains the 3 bracket ranges with answer codes 1, 2 and 3. This is on a new page.


When testing, Q2Equation shows the correct result but doesn't insert it into Q2Quota, but there is no syntax error displayed.



If I change Q2Quota to a multiple choice and update Q2Equation to:

{Q2Quota_1=if(Q2<=39 AND Q2>=18, "Y", "")}
{Q2Quota_2=if(Q2<=49 AND Q2>=40, "Y", "")}
{Q2Quota_3=if(Q2<=99 AND Q2>=50, "Y", "")}

Then it works, and is prefilling correctly.


Am I doing something wrong here, to prefill into a single choice?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 3 weeks ago #159410 by tpartner
Replied by tpartner on topic Prefilling answers to a single choice
Hmm...it works for me but I find it odd that I have different syntax highlight colours in the equation question.



Sample survey attached:

File Attachment:

File Name: limesurvey...0-09.lss
File Size:15 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • Matadeleo
  • Matadeleo's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
7 years 3 weeks ago #159412 by Matadeleo
Replied by Matadeleo on topic Prefilling answers to a single choice
Thanks for the reply tpartner, it works for me. The syntax highlighting seems different based on question order, and this affects if it works or not for me.

See table:



It seems odd that multi works and single choice doesn't with same order :blink:
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team & Official Partner
  • LimeSurvey Community Team & Official Partner
More
7 years 3 weeks ago #159434 by DenisChenu
Replied by DenisChenu on topic Prefilling answers to a single choice
About syntax : www.limesurvey.org/manual/Expression_Man...#Syntax_Highlighting

Blue color : same page
Bold pink : a page after

For equation set (use QCODE="value") remin it's set only in PHP and when validate the equation question (at the equation question step).

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member. - Professional support - Plugins, theme and development .
I don't answer to private message.
The topic has been locked.
Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose