- Posts: 4
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Change a multiple short text answer into a dropdown
- cmallen
- Topic Author
- Offline
- New Member
Less
More
5 years 2 weeks ago #182666
by cmallen
Change a multiple short text answer into a dropdown was created by cmallen
Hello, first post here. I am very new to LimeSurvey (running version 3.16.1) and was hoping to get a bit of guidance about a specific problem
I am using a multiple short text question to have my participants answer a series of short questions about a given image. For the last of these subquestions, I am hoping to have the participants select an answer from a dropdown instead of a text input.
(There are a number of these questions in sequence, thus I do not want to create a separate dropdown question if possible)
I did some initial searching on the forums and found a couple of threads asking about this problem, including some JavaScript workarounds, however all of these threads are several years old and reference older versions of the program.
Is it possible to insert a dropdown into a text field in this version? Any help would be greatly appreciated!
I am using a multiple short text question to have my participants answer a series of short questions about a given image. For the last of these subquestions, I am hoping to have the participants select an answer from a dropdown instead of a text input.
(There are a number of these questions in sequence, thus I do not want to create a separate dropdown question if possible)
I did some initial searching on the forums and found a couple of threads asking about this problem, including some JavaScript workarounds, however all of these threads are several years old and reference older versions of the program.
Is it possible to insert a dropdown into a text field in this version? Any help would be greatly appreciated!
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12880
- Thank you received: 3964
5 years 2 weeks ago #182681
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Change a multiple short text answer into a dropdown
Hi, cmallen
so you would like to have something like this?
Well, this is an array(text) with just one column.
I used tpartner's script which you find here:
www.limesurvey.org/forum/can-i-do-this-w...dropdown-list#169270
In the script there were some more requiremenrts, but I am sure you can adapt.
Example:
Best regards
Joffm
so you would like to have something like this?
Well, this is an array(text) with just one column.
I used tpartner's script which you find here:
www.limesurvey.org/forum/can-i-do-this-w...dropdown-list#169270
In the script there were some more requiremenrts, but I am sure you can adapt.
Example:
Best regards
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- cmallen
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
5 years 2 weeks ago #182695
by cmallen
Replied by cmallen on topic Change a multiple short text answer into a dropdown
Thanks for the reply, Joffm! Yes, something like that should work, provided that the text inputs can be reasonably long (though I imagine that's just an adjustment in the column size, etc.). I will try building the question as an array and modify the script you linked. Thanks again!
The topic has been locked.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12880
- Thank you received: 3964
5 years 2 weeks ago #182697
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Change a multiple short text answer into a dropdown
What is reasonably long?
The database is of type text (65656 characters)
Long enough?
If you expect real long stories as answer, you should revise your layout.
And you can take the script that is included in my example.
There you just have to adapt which row is the drop down.
Joffm
The database is of type text (65656 characters)
Long enough?
If you expect real long stories as answer, you should revise your layout.
And you can take the script that is included in my example.
There you just have to adapt which row is the drop down.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10098
- Thank you received: 3589
5 years 2 weeks ago #182720
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 Change a multiple short text answer into a dropdown
This script will insert a drop-down into the last row of a multiple-short-text question:
Code:
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ var thisQuestion = $('#question{QID}'); // Insert a select into the last row var insertRow = $('.answer-item:last', thisQuestion); $(insertRow).addClass('with-select'); if($('.inserted-select', insertRow).length == 0) { $('.answer-item:last input:text', thisQuestion).after('<select class="inserted-select form-control list-question-select">\ <option value="">Please choose...</option>\ <option value="1">Yes</option>\ <option value="2">No</option>\ <option value="3">Do not know</option>\ </select>'); } // Listeners $('.inserted-select', thisQuestion).on('change', function(i) { if($(this).val() != '') { $(this).closest('.answer-item').find('input:text').val($.trim($('option:selected', this).text())).trigger('change'); } else { $(this).closest('.answer-item').find('input:text').val('').trigger('change'); } }); // Returning to page $('.with-select input:text', thisQuestion).each(function(i) { var thisRow = $(this).closest('.answer-item'); var inputText = $.trim($(this).val()); var selectval = $('select.inserted-select option', thisRow).filter(function () { return $(this).html() == inputText; }).val(); $('select.inserted-select', thisRow).val(selectval); }); // Clean-up styles $('.with-select input:text', thisQuestion).css({ 'position': 'absolute', 'left': '-9999em' }); }); </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.
- Joffm
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 12880
- Thank you received: 3964
5 years 2 weeks ago #182723
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Change a multiple short text answer into a dropdown
Hi, Tony,
I wondered how long it will take you to show us your javascript solution.
Joffm
I wondered how long it will take you to show us your javascript solution.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The topic has been locked.
- cmallen
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
5 years 2 weeks ago #182743
by cmallen
Replied by cmallen on topic Change a multiple short text answer into a dropdown
Hi Joffm,
The answers should only be a few phrases/a sentence, so that character limit should be more than fine. I was just thinking to have the entry box be a little bigger, as in your second example image.
Cheers!
The answers should only be a few phrases/a sentence, so that character limit should be more than fine. I was just thinking to have the entry box be a little bigger, as in your second example image.
Cheers!
The topic has been locked.
- cmallen
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
5 years 2 weeks ago - 5 years 2 weeks ago #182744
by cmallen
Replied by cmallen on topic Change a multiple short text answer into a dropdown
Hi Tony,
Thanks for this! I think this will work great for what I needed!
Cheers!
Thanks for this! I think this will work great for what I needed!
Cheers!
Last edit: 5 years 2 weeks ago by cmallen.
The topic has been locked.