Dropdown in Multiple short text

More
4 years 4 months ago #95330 by Limer2001
Limer2001 replied the topic: Dropdown in Multiple short text
Thank you so much. With the QID placeholder it's working!

Please Log in to join the conversation.

More
1 year 10 months ago #128124 by petergi
petergi replied the topic: Dropdown in Multiple short text
Hi all,
the solution presented by tpartner is going into the direction I am looking for, i.e. embedding drop downs into possible answers. However, what I need is to place the drop down not at the end of an answer but rather somewhere in the sentence.
Example:

'I am looking for <dropdown> a / the </dropdown> solution.'

The user then has to select his answer only through the drop down.

Any hint for a solution is greatly appreciated.

Thanks
Peter

Please Log in to join the conversation.

More
1 week 2 days ago #158512 by ColinBrose
ColinBrose replied the topic: Dropdown in Multiple short text
Hi Tony,

Thanks for your solution. I copied your script into the source of the corresponding question but for some reason, it there is no change to the short text field in row 2, which I want to replace with a dropdown:

<p><span style="font-size:18px;">FRAGEBOGEN</span></p>
<script type="text/javascript" charset="utf-8">

$(document).ready(function() {

var qID = 134;
var inputNum = 2;

// 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>


Do you have any Ideas? Has anything changed for Version 2.67.3?

Thanks!

Please Log in to join the conversation.

More
1 week 1 day ago #158539 by tpartner
tpartner replied the topic: Dropdown in Multiple short text
This is a 4-year-old thread so, yes, many things have changed.

Please start a new thread explaining exactly what you want to achieve.

Having said that, I am on vacation, responding via phone, so will not be able to contribute any code for at least 2 weeks.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: DenisChenu

Please Log in to join the conversation.

More
1 week 1 day ago #158573 by ColinBrose
ColinBrose replied the topic: Dropdown in Multiple short text
Thanks for the hint, have a nice holiday!

Please Log in to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now