- Posts: 8
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Dropdown box in array
- Maribelcarol
-
Topic Author
- Offline
- New Member
-
Less
More
2 years 8 months ago #205317
by Maribelcarol
Dropdown box in array was created by Maribelcarol
Hi,
So I'd like to have dropdown boxes in an array. I have this script but I keep seeing the numbers in the dropdown. I just want to see the words. Could somebody help me with this?
Thanks!
So I'd like to have dropdown boxes in an array. I have this script but I keep seeing the numbers in the dropdown. I just want to see the words. Could somebody help me with this?
Code:
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ var thisQuestion = $('#question{QID}'); // Insert selects $('.answer-item', thisQuestion).append('<select class="inserted-select form-control list-question-select">\ <option value="">Please choose...</option>\ <option value="1">Fraxinus spp.</option>\ <option value="2">Gleditsia triacanthos</option>\ <option value="3">Gymnocladus dioicus</option>\ <option value="4">Platanus x acerifolia</option>\ <option value="5">Thuja spp.</option>\ <option value="6">Ulmus spp</option>\ <option value="7">Celtis spp.</option>\ <option value="8">Gingkgo biloba</option>\ <option value="9">Pyrus spp.</option>\ </select>'); // Listeners $('.inserted-select', thisQuestion).on('change', function(i) { if($(this).val() != '') { $(this).closest('.answer-item').find('input:text').val($.trim($(this).val())).trigger('change'); } else { $(this).closest('.answer-item').find('input:text').val('').trigger('change'); } }); // Returning to page $('input:text', thisQuestion).each(function(i) { var thisCell = $(this).closest('.answer-item'); var inputVal = $.trim($(this).val()); $('select.inserted-select', thisCell).val(inputVal); }); // Clean-up styles $('select.inserted-select', thisQuestion).css({ 'max-width': '100%' }); $('input:text', thisQuestion).css({ 'position': 'absolute', 'left': '-9999em' }); }); </script>
Thanks!
The topic has been locked.
2 years 8 months ago - 2 years 8 months ago #205322
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Dropdown box in array
Obviously you did not set "Checkbox Layout" to "Off" and "Text Inputs" to "On".
But why don't you use a question of type ranking for this?
You can set it that only five trees are selected.
Joffm
But why don't you use a question of type ranking for this?
You can set it that only five trees are selected.
Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last edit: 2 years 8 months ago by Joffm.
The topic has been locked.
- Maribelcarol
-
Topic Author
- Offline
- New Member
-
Less
More
- Posts: 8
- Thank you received: 0
2 years 8 months ago #205323
by Maribelcarol
Replied by Maribelcarol on topic Dropdown box in array
That's true! Thank you so much!
I prefere it like this for the design of the survey.
I prefere it like this for the design of the survey.
The topic has been locked.
2 years 8 months ago #205324
by Joffm
Volunteers are not paid.
Not because they are worthless, but because they are priceless
Replied by Joffm on topic Dropdown box in array
Don't forget to validate with "unique(self)"
Volunteers are not paid.
Not because they are worthless, but because they are priceless
The following user(s) said Thank You: Maribelcarol
The topic has been locked.