Prefilling answers to a single choice

More
1 month 1 week ago #159405 by Matadeleo
Matadeleo created the topic: Prefilling answers to a single choice
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?

Please Log in to join the conversation.

More
1 month 1 week ago #159410 by tpartner
tpartner replied the 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.
Attachments:

Please Log in to join the conversation.

More
1 month 1 week ago #159412 by Matadeleo
Matadeleo replied the 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:

Please Log in to join the conversation.

More
1 month 1 week ago #159434 by DenisChenu
DenisChenu replied the topic: Prefilling answers to a single choice
About syntax : manual.limesurvey.org/Expression_Manager#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 service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!