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.
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:
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.