- Posts: 7
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Can I fill a field with responses from other fields?
- caitifty
- Topic Author
- Offline
- New Member
Less
More
8 years 8 months ago #122172
by caitifty
Can I fill a field with responses from other fields? was created by caitifty
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
Can this be done with expression manager or does it require javascript? Either way, any pointers would be much appreciated.
Pete
The topic has been locked.
- first
- Offline
- Elite Member
Less
More
- Posts: 256
- Thank you received: 37
8 years 8 months ago #122174
by first
Survey Designer and Programmer
Replied by first on topic Can I fill a field with responses from other fields?
See if this helps
manual.limesurvey.org/Workarounds:_Manip...oss_multiple_surveys
Survey Designer and Programmer
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
8 years 8 months ago - 8 years 8 months ago #122197
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 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:
- 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:
Code:
{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: 8 years 8 months ago by tpartner.
The topic has been locked.