Pre-populating answers with custom token attributes

More
4 years 1 week ago - 4 years 1 week ago #113304 by tpartner
tpartner replied the 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)}

.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 4 years 1 week ago by tpartner.

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

More
8 months 3 weeks ago #163353 by abudzarr
abudzarr replied the 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

https://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. https://snag.gy/5anUIN.jpg

Will appreciate if someone can point out where did I go wrong.

Thanks

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

More
8 months 3 weeks ago - 8 months 3 weeks ago #163359 by tpartner
tpartner replied the topic: Pre-populating answers with custom token attributes
The script should be:

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

{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: 8 months 3 weeks ago by tpartner.
The following user(s) said Thank You: jpperrein, abudzarr

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!