- Posts: 14
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Pre-populating answers with custom token attributes
- jpperrein
- Offline
- New Member
Less
More
9 years 6 months ago #113296
by jpperrein
Replied by jpperrein on topic Pre-populating answers with custom token attributes
Hi,
Ok, many thanks, indeed, I can choose a default value for text purpose. That works fine.
But what if I want to set the default value to an {TOKEN:ATTRIBUTE_1} to a List (radio) question ? - I do not have any place to add my variable, like the text one.
Any clues ?
Many thanks
Ok, many thanks, indeed, I can choose a default value for text purpose. That works fine.
But what if I want to set the default value to an {TOKEN:ATTRIBUTE_1} to a List (radio) question ? - I do not have any place to add my variable, like the text one.
Any clues ?
Many thanks
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10115
- Thank you received: 3597
9 years 6 months ago #113299
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 Pre-populating answers with custom token attributes
To set defaults for radio questions you can use the Expression Manager Assignment operator in a following equation type question -
manual.limesurvey.org/Expression_Manager..._Assignment_Operator
Be sure to make it conditional on the radio being unanswered. Something like:
.
Be sure to make it conditional on the radio being unanswered. Something like:
Code:
{qRADIO = if(qRADIO == "", TOKEN:ATTRIBUTE_1, qRADIO)}
.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- jpperrein
- Offline
- New Member
Less
More
- Posts: 14
- Thank you received: 0
9 years 6 months ago #113303
by jpperrein
Replied by jpperrein on topic Pre-populating answers with custom token attributes
Re,
Ok, the condition is a good thing, thanks.
But I did test it and it does fill the question text but do not change anything on the answer :
What I have done : (ATTRIBUTE_1 = CAT1)
CODE : categorie
QUESTION: Hello, this is my question ... ?
{Categorie = if(Categorie == "", TOKEN:ATTRIBUTE_1, Categorie)}
HELP :nohelp
And the result is
TEXT of QUESTION : Hello, this is my question ... ?
CAT1
O Catégorie 1 (do have the code CAT1)
O Catégorie 2 (do have the code CAT2)
O Catégorie 3 (do have the code CAT3)
So it does "write" CAT1, but on the text of the question, not changing the value of the choice itself.
Hard to explain, sorry :side: .Do you see the issue ?
Many thanks for your help.
Ok, the condition is a good thing, thanks.
But I did test it and it does fill the question text but do not change anything on the answer :
What I have done : (ATTRIBUTE_1 = CAT1)
CODE : categorie
QUESTION: Hello, this is my question ... ?
{Categorie = if(Categorie == "", TOKEN:ATTRIBUTE_1, Categorie)}
HELP :nohelp
And the result is
TEXT of QUESTION : Hello, this is my question ... ?
CAT1
O Catégorie 1 (do have the code CAT1)
O Catégorie 2 (do have the code CAT2)
O Catégorie 3 (do have the code CAT3)
So it does "write" CAT1, but on the text of the question, not changing the value of the choice itself.
Hard to explain, sorry :side: .Do you see the issue ?
Many thanks for your help.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10115
- Thank you received: 3597
9 years 6 months ago - 9 years 6 months ago #113304
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 Pre-populating answers with custom token attributes
You need to put the expression into a hidden equation type question that follows categorie.
Question type - single-choice-radio
Question code - categorie
Question text - Hello, this is my question ... ?
Answers - Catégorie 1 (code CAT1), Catégorie 2 (code CAT2), Catégorie 3 (code CAT3)
Question type - equation
Question code - catControl
"Always hide this question" - yes
Question text - {categorie = if(categorie == "", TOKEN:ATTRIBUTE_1, categorie)}
.
Question type - single-choice-radio
Question code - categorie
Question text - Hello, this is my question ... ?
Answers - Catégorie 1 (code CAT1), Catégorie 2 (code CAT2), Catégorie 3 (code CAT3)
Question type - equation
Question code - catControl
"Always hide this question" - yes
Question text - {categorie = if(categorie == "", TOKEN:ATTRIBUTE_1, categorie)}
.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 9 years 6 months ago by tpartner.
The topic has been locked.
- abudzarr
- Offline
- New Member
Less
More
- Posts: 6
- Thank you received: 0
6 years 3 months ago #163353
by abudzarr
Replied by abudzarr on topic Pre-populating answers with custom token attributes
I have got a similar problem, and I have tried to follow the recommendation suggested here.
Linked below is the script I have entered
snag.gy/hiI2HD.jpg
I would expect that the short-text answer would be auto-filled with token attributes
but I failed to get the expected result. snag.gy/5anUIN.jpg
Will appreciate if someone can point out where did I go wrong.
Thanks
Linked below is the script I have entered
snag.gy/hiI2HD.jpg
I would expect that the short-text answer would be auto-filled with token attributes
but I failed to get the expected result. snag.gy/5anUIN.jpg
Will appreciate if someone can point out where did I go wrong.
Thanks
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10115
- Thank you received: 3597
6 years 3 months ago - 6 years 3 months ago #163359
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 Pre-populating answers with custom token attributes
The script should be:
You could also do it by placing a hidden (via CSS class) equation question directly after R01 with this equation:
Code:
<script> $(document).ready(function() { $("#question{QID} input.text").val('{TOKEN:EMAIL}'); }); </script>
You could also do it by placing a hidden (via CSS class) equation question directly after R01 with this equation:
Code:
{R01 = (is_empty(R01), TOKEN:EMAIL, R01)}
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 6 years 3 months ago by tpartner.
The following user(s) said Thank You: jpperrein, abudzarr
The topic has been locked.