# Prefilling answers to a single choice

il y a 1 an 2 semaines #159405 par Matadeleo
Matadeleo a créé le sujet : 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?

Connexion ou Créer un compte pour participer à la conversation.

il y a 1 an 2 semaines #159410 par tpartner
tpartner a répondu au sujet : 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:

#### Fichier attaché :

Nom du fichier : limesurvey...0-09.lss
Taille du ficher :15 ko

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
##### Pièces jointes :

Connexion ou Créer un compte pour participer à la conversation.

il y a 1 an 2 semaines #159412 par Matadeleo
Matadeleo a répondu au sujet : 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

Connexion ou Créer un compte pour participer à la conversation.

il y a 1 an 1 semaine #159434 par DenisChenu
DenisChenu a répondu au sujet : Prefilling answers to a single choice

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 .

Connexion ou Créer un compte pour participer à la conversation.