Can I fill a field with responses from other fields?

Plus d'informations
il y a 3 ans 9 mois #122172 par caitifty
COM_KUNENA_MESSAGE_CREATED_NEW
I have a survey where the user enters a 'code' made up of their first and last initial plus the first two letters of their mother's first name plus the day of the month on which they were born, eg My name is Peter D, my mother's first name is Hazel, and I was born on October 20, so my code would be PDHA20 (the idea is to have something relatively anonymous and relatively unique but easy for people to reproduce in 6 months time). It's been suggested that to make things easy I add optional questions for firstname, lastname, mother's firstname, and date of birth, then if the user chooses to answer these questions the 'code' field gets autopopulated with the correct code (otherwise they just work the code out themselves and enter that).

Can this be done with Expression Manager or does it require javascript? Either way, any pointers would be much appreciated.

Pete

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

Plus d'informations
il y a 3 ans 9 mois #122174 par first
COM_KUNENA_MESSAGE_REPLIED_NEW

Survey Designer and Programmer

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

Plus d'informations
il y a 3 ans 9 mois - il y a 3 ans 9 mois #122197 par tpartner
COM_KUNENA_MESSAGE_REPLIED_NEW
Given, for example, the following questions codes...

- fName (First Name)
- lName (Last Name)
- mfName (Mother's First Name)
- dob (Date of Birth)

...you could use an expression like this in the "Default answer" setting for the "code" question:

{if(!is_empty(fName) AND !is_empty(lName) AND !is_empty(mfName) AND !is_empty(dob), strtoupper(substr(fName, 0, 1)+substr(lName, 0, 1)+substr(mfName, 0, 2)+substr(dob, 5, 2)), '')}

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: il y a 3 ans 9 mois by tpartner.

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

Commencez dès maintenant !

Créez simplement un compte et commencez à utiliser LimeSurvey dès aujourd'hui.

Inscrivez-vous maintenant

Inscrivez-vous à notre Newsletter!