- Posts: 45
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
replace placeholder linked to an answer to another question
- Thomassie
- Topic Author
- Offline
- Senior Member
Less
More
8 years 6 months ago #125656
by Thomassie
replace placeholder linked to an answer to another question was created by Thomassie
Hello,
In my survey people must choose a person's name from a dropdown list. In later questions the name of that person reappears in the question. In that question there is also a "he/she" placeholder. Is there a possibility to replace this "he/she" placeholder with the appropriate "he" or "she" and this without having to create a visible question male/female ?
In my survey people must choose a person's name from a dropdown list. In later questions the name of that person reappears in the question. In that question there is also a "he/she" placeholder. Is there a possibility to replace this "he/she" placeholder with the appropriate "he" or "she" and this without having to create a visible question male/female ?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
8 years 6 months ago #125661
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 replace placeholder linked to an answer to another question
You could prepend the name answer codes with an "M" or "F" depending on gender. Then, in the subsequent questions, you can use the Expression Manager
substr() function
in an IF() statement to detect that first character and show the appropriate pronoun.
Code:
{if(substr(qName, 0, 1) == 'M', 'he', 'she')}
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- Thomassie
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 45
- Thank you received: 0
8 years 6 months ago #125663
by Thomassie
Replied by Thomassie on topic replace placeholder linked to an answer to another question
Thanks that will probably do the trick. Just some clarifications, because I am a real no(o)b with Limesurvey, How would you "prepend" 'M' or 'F' in the answercode ? or is it in the answerbox ?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
8 years 6 months ago #125665
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 replace placeholder linked to an answer to another question
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The topic has been locked.
- Thomassie
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 45
- Thank you received: 0
8 years 6 months ago #125667
by Thomassie
Replied by Thomassie on topic replace placeholder linked to an answer to another question
thanks, I feared it was in the answercode (as you stated in your original answer). I will have to change my codes because in some cases they already consist of 5 characters (and the maximum characterlength for the answercode is 5).
thanks again for your solution !!
greetings
thomas
thanks again for your solution !!
greetings
thomas
The topic has been locked.
- Thomassie
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 45
- Thank you received: 0
8 years 6 months ago #125722
by Thomassie
Replied by Thomassie on topic replace placeholder linked to an answer to another question
I tried the solution Tony gave.
the code works only half
I put this code in my question {if(substr(A41,1,0)=='V','hij','zij'} .
Question A41 has a dropdown menu (the possible answercodes are A41A, A41B, A41C,...) In the codes that refer to a female employee I put a "V" before the code (so I get VA41A,VA41B,...) the result is that in my question the word "zij" (dutch for she) appears, which is what I want, however the codes without V also give "zij" as a result.
what am I doing wrong ?
the code works only half
I put this code in my question {if(substr(A41,1,0)=='V','hij','zij'} .
Question A41 has a dropdown menu (the possible answercodes are A41A, A41B, A41C,...) In the codes that refer to a female employee I put a "V" before the code (so I get VA41A,VA41B,...) the result is that in my question the word "zij" (dutch for she) appears, which is what I want, however the codes without V also give "zij" as a result.
what am I doing wrong ?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
8 years 6 months ago #125724
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 replace placeholder linked to an answer to another question
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The topic has been locked.
- Thomassie
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 45
- Thank you received: 0
8 years 6 months ago #125726
by Thomassie
Replied by Thomassie on topic replace placeholder linked to an answer to another question
Thanks Tony,
I've found my mistake. I thought it was sufficient to leave out a letter for the opposite sex (so I had "V" before female names, and I left the code unchanged for the males), but apparently I needed to put a letter in the male codes also.
Now it works like a charm.
thanks
thomas
I've found my mistake. I thought it was sufficient to leave out a letter for the opposite sex (so I had "V" before female names, and I left the code unchanged for the males), but apparently I needed to put a letter in the male codes also.
Now it works like a charm.
thanks
thomas
The topic has been locked.
- Thomassie
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 45
- Thank you received: 0
8 years 6 months ago #125729
by Thomassie
Replied by Thomassie on topic replace placeholder linked to an answer to another question
Still have a small problem, when I combine these codes, they all give a response.
example.
code in the question is
blablabla {if(substr(A41,1,0)=='V','he',shej'} {if(substr(A42,1,0)=='V','he','she'} {if(substr(A43,1,0)=='V','he','she'} {if(substr(A44,1,0)=='V','he','she'} blablabla.
So even when there is no answer to question A41,A42 and A43 and only A44 gets answered, I still get sheshesheshe instead of a single she.
Is there a solution to make these "she" answers invisible when not answered ?
example.
code in the question is
blablabla {if(substr(A41,1,0)=='V','he',shej'} {if(substr(A42,1,0)=='V','he','she'} {if(substr(A43,1,0)=='V','he','she'} {if(substr(A44,1,0)=='V','he','she'} blablabla.
So even when there is no answer to question A41,A42 and A43 and only A44 gets answered, I still get sheshesheshe instead of a single she.
Is there a solution to make these "she" answers invisible when not answered ?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
8 years 6 months ago #125733
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 replace placeholder linked to an answer to another question
I had no idea you are using several name questions. In that case, you will need to use nested IF statements. What letters are you using foe the male and female answer codes?
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- Thomassie
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 45
- Thank you received: 0
8 years 6 months ago #125736
by Thomassie
Replied by Thomassie on topic replace placeholder linked to an answer to another question
the codes are like this
VA41A MA42A
MA41B MA42B
VA41C VA42C
so, the 'V' is for females and the 'M' for males.
The reason I'm using different dropdownmenu's (and different questions A41,A42,...)is because I want to filter out names, so the dropdownmenu with names doesn't become too long.
People first get the question which department the employee works and then on which floor. Each answer is linked to a dropdownmenu.
VA41A MA42A
MA41B MA42B
VA41C VA42C
so, the 'V' is for females and the 'M' for males.
The reason I'm using different dropdownmenu's (and different questions A41,A42,...)is because I want to filter out names, so the dropdownmenu with names doesn't become too long.
People first get the question which department the employee works and then on which floor. Each answer is linked to a dropdownmenu.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
8 years 6 months ago #125738
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 replace placeholder linked to an answer to another question
Okay, in that case, something like this which effectively says for each name question:
- If the answer is "V", pronoun is "she"
- Else If the answer is "M", pronoun is "he"
- Else the pronoun is null
(line breaks insrted for clarity)
- If the answer is "V", pronoun is "she"
- Else If the answer is "M", pronoun is "he"
- Else the pronoun is null
(line breaks insrted for clarity)
Code:
{if(substr(A41,1,0) == 'V', 'she', if(substr(A41,1,0) == 'M', 'he', ''))} {if(substr(A42,1,0) == 'V', 'she', if(substr(A42,1,0) == 'M', 'he', ''))} {if(substr(A43,1,0) == 'V', 'she', if(substr(A43,1,0) == 'M', 'he', ''))} {if(substr(A44,1,0) == 'V', 'she', if(substr(A44,1,0) == 'M', 'he', ''))}
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.