- Posts: 107
- Thank you received: 4
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Prefilling answers to a single choice
- Matadeleo
- Topic Author
- Offline
- Premium Member
Less
More
6 years 6 months 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?
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
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10099
- Thank you received: 3589
6 years 6 months ago #159410
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
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:
Sample survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The topic has been locked.
- Matadeleo
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 107
- Thank you received: 4
6 years 6 months ago #159412
by Matadeleo
Replied by Matadeleo on topic Prefilling answers to a single choice
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13597
- Thank you received: 2487
6 years 6 months ago #159434
by DenisChenu
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.
Replied by DenisChenu on 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).
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 , plugin development .
I don't answer to private message.
The topic has been locked.