Dropdown box in array

More
1 week 2 days ago #205317 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?
<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!
Attachments:

Please Log in to join the conversation.

LimeSurvey Partners
More
1 week 2 days ago - 1 week 2 days ago #205322 by Joffm
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


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Attachments:
Last edit: 1 week 2 days ago by Joffm.

Please Log in to join the conversation.

More
1 week 2 days 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.

Please Log in to join the conversation.

More
1 week 2 days ago #205324 by Joffm
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

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now