Can I fill a field with responses from other fields?

More
3 years 3 months ago #122172 by caitifty
caitifty created the topic: Can I fill a field with responses from other fields?
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

Please Log in or Create an account to join the conversation.

More
3 years 3 months ago #122174 by first
first replied the topic: Can I fill a field with responses from other fields?

Survey Designer and Programmer

Please Log in or Create an account to join the conversation.

More
3 years 3 months ago - 3 years 3 months ago #122197 by tpartner
tpartner replied the topic: Can I fill a field with responses from other fields?
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: 3 years 3 months ago by tpartner.

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!