List dropdown in multiple short text question

More
1 year 1 week ago #158559 by ColinBrose
ColinBrose created the topic: List dropdown in multiple short text question
Dear Limesurvey community,

I am currently creating a survey in which I intend to use a multiple short text question. Within that question, I would like to replace one short text box with a dropdown list. I thought that I had found what I was looking for in this post: www.limesurvey.org/forum/can-i-do-this-w...-multiple-short-text

The post told me to insert the following code into the source of the corresponding question:


<script type="text/javascript" charset="utf-8">

$(document).ready(function() {

var qID = {QID};
var inputNum = 4;

// Define the select element (dropdown)
var select1 = '<select id="select1"> \
<option value="">-- Please Choose --</option> \
<option value="Apples">Apples</option> \
<option value="Oranges">Oranges</option> \
<option value="Pears">Pears</option> \
<option value="Bananas">Bananas</option> \
</select>';

// Hide the text input
$('#question'+qID+' li:eq('+(inputNum-1)+') input.text').hide().parent().hide();

// Insert the select elements
$('#question'+qID+' li:eq('+(inputNum-1)+')').append(select1);

// Initially select an option if the question has already been answered
if($('#question'+qID+' li:eq('+(inputNum-1)+') input.text').val()) {
$('#question'+qID+' li:eq('+(inputNum-1)+') select').val($('#question'+qID+' li:eq('+(inputNum-1)+') input.text').val())
}

// Listener on the dropdowns - insert selected values into hidden text input
$('#question'+qID+' select').change(function() {
$(this).siblings('span').children('input.text').val($(this).val());
});

// Some styles
$('#question'+qID+' select').css({
'margin':'0.3em 0 0 1em'
});
});

</script>


As the post is 5 years old, clearly things must have changed and inserting the code yielded no result. I would be grateful for any helpful hints on how to insert the dropdown!

Thanks a lot,

Colin
using LimeSurvey Version 2.67.3

Please Log in or Create an account to join the conversation.

More
5 months 1 week ago #167155 by AWGAWG
AWGAWG replied the topic: List dropdown in multiple short text question
Reviving the thread since I'm experiencing the same problem: that code doesn't turn a short text field in a dropdown.

Please Log in or Create an account to join the conversation.

More
5 months 1 week ago - 5 months 1 week ago #167158 by Joffm
Joffm replied the topic: List dropdown in multiple short text question
Hi,

the code of this post is originally 6 years old and about LS version 1.9x.
As Colin said, it doesn't work in the 2.50- branch and will not wortk in the 3.x branch.
So, better you stay to your other thread.

Joffm


Volunteers are not paid.
Not because they are worthless, but because they are priceless
Last Edit: 5 months 1 week ago by Joffm.

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!