Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
prefill questions based on attribute's in the token table
- Mazi
- Offline
- Official LimeSurvey Partner
Less
More
10 years 6 months ago - 10 years 6 months ago #99793
by Mazi
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
Replied by Mazi on topic prefill questions based on attribute's in the token table
duvemyster, I am not quite sure what you are up to, but maybe this helps:
Pre-filling a text field at Limesurvey 1.92 using default answers and Expression Manager
Pre-filling a text field at Limesurvey 1.92 using default answers and Expression Manager
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
Last edit: 10 years 6 months ago by Mazi.
The topic has been locked.
- duvemyster
- Offline
- Senior Member
Less
More
- Posts: 60
- Thank you received: 6
10 years 6 months ago #99798
by duvemyster
Replied by duvemyster on topic prefill questions based on attribute's in the token table
I was trying to pull the default answer in from the token table on a multiple short-text question in 2.00+ .
Should entering {TOKEN:ATTRIBUTE_1} in a default field of a multiple short-text question be working?
Should entering {TOKEN:ATTRIBUTE_1} in a default field of a multiple short-text question be working?
The topic has been locked.
- Mazi
- Offline
- Official LimeSurvey Partner
10 years 6 months ago #99806
by Mazi
...the answer is "yes".
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
Replied by Mazi on topic prefill questions based on attribute's in the token table
Just give it a try...duvemyster wrote: Should entering {TOKEN:ATTRIBUTE_1} in a default field of a multiple short-text question be working?
...the answer is "yes".
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
The topic has been locked.
- duvemyster
- Offline
- Senior Member
Less
More
- Posts: 60
- Thank you received: 6
10 years 6 months ago #99808
by duvemyster
Replied by duvemyster on topic prefill questions based on attribute's in the token table
Thank you, Mazi.
I haven't figured out yet what I was doing differently yesterday, though this has been working perfectly for me each time today.
I haven't figured out yet what I was doing differently yesterday, though this has been working perfectly for me each time today.
The following user(s) said Thank You: mayeulk01
The topic has been locked.
- Anana
- Offline
- New Member
Less
More
- Posts: 8
- Thank you received: 0
7 years 10 months ago #135512
by Anana
Replied by Anana on topic prefill questions based on attribute's in the token table
Hi Joost,
Thank you for your input on this question, I am using your code to pre-fill a limewurvey questionnaire using the last version of lime survey, and it works perfectly!!
However, I have an issue pre-filling a single choice question, but uisng a dropdown list instead of a radio list. The code provided on this forum is not working as soon as we select a dropdown format. As I have some long list (e.g countries code) to fill in, it would be very convenient to use a dropdown.
Did you by any chance already encounter the same issue? Or would you have a solution to pre-fill a dropdown? I haven't found any by far.
Thanks in advance and all the best!
Thank you for your input on this question, I am using your code to pre-fill a limewurvey questionnaire using the last version of lime survey, and it works perfectly!!
However, I have an issue pre-filling a single choice question, but uisng a dropdown list instead of a radio list. The code provided on this forum is not working as soon as we select a dropdown format. As I have some long list (e.g countries code) to fill in, it would be very convenient to use a dropdown.
Did you by any chance already encounter the same issue? Or would you have a solution to pre-fill a dropdown? I haven't found any by far.
Thanks in advance and all the best!
The topic has been locked.
- Mazi
- Offline
- Official LimeSurvey Partner
7 years 10 months ago #135519
by Mazi
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
Replied by Mazi on topic prefill questions based on attribute's in the token table
1. Did the solution work for drop downs at previous Limesurvey versions?
2. Please post a link to a short sample survey.
2. Please post a link to a short sample survey.
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
The topic has been locked.
- Anana
- Offline
- New Member
Less
More
- Posts: 8
- Thank you received: 0
7 years 10 months ago #135538
by Anana
Replied by Anana on topic prefill questions based on attribute's in the token table
Thanks for your answer.
1. We never tried it for drop downs at previous versions, we did it here for the first time.
2. For instance, we want to create a drop down list of 4 choices for the respondents, asking them to select the role of their institution (NSO/ Academi/ Private sector, IO). See excel sheet. The code works perfectly for pre-filling a radio list, but does not prefill for dropdown. I am using the code below:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
if('{TOKEN:ATTRIBUTE_1}' == 'NSO') $("input#answer38934X2077X29244A1").attr('checked', true);
if('{TOKEN:ATTRIBUTE_1}' == 'Academia') $("input#answer38934X2077X29244A2").attr('checked', true);
if('{TOKEN:ATTRIBUTE_1}' == 'Private Sector') $("input#answer38934X2077X29244A3").attr('checked', true);
if('{TOKEN:ATTRIBUTE_1}' == 'IO') $("input#answer38934X2077X29244A4").attr('checked', true);
});
</script>
With A1 to A4 being the corresponding answer options for this question.
1. We never tried it for drop downs at previous versions, we did it here for the first time.
2. For instance, we want to create a drop down list of 4 choices for the respondents, asking them to select the role of their institution (NSO/ Academi/ Private sector, IO). See excel sheet. The code works perfectly for pre-filling a radio list, but does not prefill for dropdown. I am using the code below:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
if('{TOKEN:ATTRIBUTE_1}' == 'NSO') $("input#answer38934X2077X29244A1").attr('checked', true);
if('{TOKEN:ATTRIBUTE_1}' == 'Academia') $("input#answer38934X2077X29244A2").attr('checked', true);
if('{TOKEN:ATTRIBUTE_1}' == 'Private Sector') $("input#answer38934X2077X29244A3").attr('checked', true);
if('{TOKEN:ATTRIBUTE_1}' == 'IO') $("input#answer38934X2077X29244A4").attr('checked', true);
});
</script>
With A1 to A4 being the corresponding answer options for this question.
Attachments:
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
7 years 10 months ago #135546
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 prefill questions based on attribute's in the token table
You need to do something like this for drop-downs (select elements):
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { if('{TOKEN:ATTRIBUTE_1}' == 'NSO' && $('#answer38934X2077X29244').val() == '') { $('#answer38934X2077X29244 option').removeAttr('selected'); $('#answer38934X2077X29244 option[value="A1"]').attr('selected', 'selected'); $('#answer38934X2077X29244').val('A1'); } if('{TOKEN:ATTRIBUTE_1}' == 'Academia' && $('#answer38934X2077X29244').val() == '') { $('#answer38934X2077X29244 option').removeAttr('selected'); $('#answer38934X2077X29244 option[value="A2"]').attr('selected', 'selected'); $('#answer38934X2077X29244').val('A2'); } if('{TOKEN:ATTRIBUTE_1}' == 'Private Sector' && $('#answer38934X2077X29244').val() == '') { $('#answer38934X2077X29244 option').removeAttr('selected'); $('#answer38934X2077X29244 option[value="A3"]').attr('selected', 'selected'); $('#answer38934X2077X29244').val('A3'); } if('{TOKEN:ATTRIBUTE_1}' == 'IO' && $('#answer38934X2077X29244').val() == '') { $('#answer38934X2077X29244 option').removeAttr('selected'); $('#answer38934X2077X29244 option[value="A4"]').attr('selected', 'selected'); $('#answer38934X2077X29244').val('A4'); } }); </script>
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- Anana
- Offline
- New Member
Less
More
- Posts: 8
- Thank you received: 0
7 years 10 months ago #135548
by Anana
Replied by Anana on topic prefill questions based on attribute's in the token table
Thank you very much, I'll test it!
Cheers
Cheers
The topic has been locked.
- akankashasharma91
- Offline
- New Member
Less
More
- Posts: 1
- Thank you received: 0
6 years 1 month ago #163502
by akankashasharma91
Replied by akankashasharma91 on topic prefill questions based on attribute's in the token table
Hi
I require an urgent help in case of an anonymous survey i want a token field value to be stored in a question which will be of equation type. But i am not able to do it using the above mentioned solution.
Please help.
Thanks in advance.
I require an urgent help in case of an anonymous survey i want a token field value to be stored in a question which will be of equation type. But i am not able to do it using the above mentioned solution.
Please help.
Thanks in advance.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10611
- Thank you received: 3690
6 years 1 month ago #163515
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 prefill questions based on attribute's in the token table
This thread has nothing to do with equation type questions. To prefill that question type, you would simply place something like this in the question text - {TOKEN:ATTRIBUTE_1}.
Having said that, if your survey is anonymous, there is no connection to the token table so you cannot access token attributes from within the survey.
manual.limesurvey.org/Participant_settings
Having said that, if your survey is anonymous, there is no connection to the token table so you cannot access token attributes from within the survey.
manual.limesurvey.org/Participant_settings
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.