- Posts: 13
- Thank you received: 1
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Pre-populating answers with custom token attributes
- tacman1123
- Topic Author
- Offline
- LimeSurvey Community Team
Our records show that your email address is {TOKEN:EMAIL}. If this is not correct, add the new email below.
But then it will only work if the survey is taken via a token.
What I really want is to pre-populate the answers based on the token (if the survey is taken that way). Otherwise it'd just be the default, e.g.
Please enter your email:
and then have the answer there.
I was hoping to see a Default Answer in the Advanced Options, with the ability to add {TOKEN:EMAIL} as the default.
Is there another way to do this easily?
Thx,
Tac
- fransmarcelissen
- Offline
- Premium Member
- Posts: 113
- Thank you received: 46
Good news, what you want is exactly what I do in my questionnaires in 1.92rc3. 1.92 has the option of defining defaults for text fields. But the defaults are not in the advanced options, but as a button along the conditions button. As a default you can set {TOKEN:EMAIL}, so the user can keep this or change it if he wants. The default can also be a EM script. Of course the TOKEN does not change.
Frans
- Mazi
- Offline
- Official LimeSurvey Partner
Thanks!
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
- tacman1123
- Topic Author
- Offline
- LimeSurvey Community Team
- Posts: 13
- Thank you received: 1
Is there a way to check for the existence of a token before using it? For example, if I have a field called "industry" in my token list (ATTRIBUTE_1), but the token table hasn't been initialized yet, I just want it to be blank. So maybe something like
Default: IF isset({TOKEN:ATTRIBUTE_1}) TOKEN:ATTRIBUTE_1 ELSE "";
Is that something that's even possible?
Or is there another approach that would work better? In particular, I want to be able to give a link to someone and say "Please review this survey" and not have it fail if I have default answers that will be populated if it's coming from a token-based survey.
Thx,
Tac
- Mazi
- Offline
- Official LimeSurvey Partner
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
- DenisChenu
- Offline
- LimeSurvey Community Team
- Posts: 13647
- Thank you received: 2491
I think you can use:
A token table for invitation, set to no-anonymous.
A token with : newinscription for tokencode, set to 1000000 answer ( or more .
And in the survey you can use condition to show:
Your email: please put your mail adress: < input >
OR:
Can you confirm your mail adresse YES/NO
( if no : give an new question with your email )
You can fill to an input with the email for token table.
( $("#question"+QQ+" input.text").val('{TOKEN:EMAIL}');
Denis
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
- ricardo01
- Offline
- Junior Member
- Posts: 26
- Thank you received: 1
A token table for invitation, set to no-anonymous. DONE
A token with : newinscription for tokencode, set to 1000000 answer ( or more) How? What is a"newinscription" How can I set it to 1000000? where?
You can fill to an input with the email for token table.
( $("#question"+QQ+" input.text").val('{TOKEN:EMAIL}'); Where do I write this?
Thanks!
- Mazi
- Offline
- Official LimeSurvey Partner
I think Denis was talking about the "uses_left" column at which you can define the number of times a certain token can be used.ricardo wrote: A token with : newinscription for tokencode, set to 1000000 answer ( or more) How? What is a"newinscription" How can I set it to 1000000? where?
Try adding this code at the source code mode of the editor at the related question:ricardo wrote: You can fill to an input with the email for token table.
( $("#question"+QQ+" input.text").val('{TOKEN:EMAIL}'); Where do I write this?
<script> $(document).ready(function() { $("#question"+QQ+" input.text").val('{TOKEN:EMAIL}'); }); </script>
Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
- ricardo01
- Offline
- Junior Member
- Posts: 26
- Thank you received: 1
My question ID is 4903...and this is the script I'm using...is this correct?
<script>
$(document).ready(function()
{
$("#question"+4903+"input.text").val('{TOKEN:EMAIL}');
});
</script>
it's not prepopulating anything yet
- Ben_V
- Offline
- Platinum Member
- Posts: 1128
- Thank you received: 329
Wrong:
$("#question"+4903+"input.text").val('{TOKEN:EMAIL}');
Correct:
$("#question"+4903+" input.text").val('{TOKEN:EMAIL}');
Ben/
Benoît
EM Variables => bit.ly/1TKQyNu | EM Roadmap => bit.ly/1UTrOB4
Last Releases => 2.6x.x goo.gl/ztWfIV | 2.06/2.6.x => bit.ly/1Qv44A1
Demo Surveys => goo.gl/HuR6Xe (already included in /docs/demosurveys)
- jpperrein
- Offline
- New Member
- Posts: 14
- Thank you received: 0
fransmarcelissen wrote: Hi,
Good news, what you want is exactly what I do in my questionnaires in 1.92rc3. 1.92 has the option of defining defaults for text fields. But the defaults are not in the advanced options, but as a button along the conditions button. As a default you can set {TOKEN:EMAIL}, so the user can keep this or change it if he wants. The default can also be a EM script. Of course the TOKEN does not change.
Frans
Hi, I canno't make this working. The condition part ask me to create a condition. Must be a trick to use it so a default value based on invitation table can be used.
Any clues, would it be possible to have an example ?
Many thanks
- tpartner
- Offline
- LimeSurvey Community Team
- Posts: 10109
- Thank you received: 3595
.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.