Does anyone know how to insert a text array and a column to be the Dropdown type?
I used this feature to last year, but it seems that after upgrading from Limesurvey stopped working. Follows the code.
2.1 Indique o tipo de evento, nome do evento e instituição, nome do artista e tipo de apoio:
// Define the select element (dropdown)
var select1 = '<select class="insertedSelect"> \
<option value="">-- Selecione o tipo de evento --</option> \
<option value="1">Exposição institucional coletiva</option> \
<option value="2">Exposição institucional individual</option> \
<option value="3">Exposição coletiva em galeria comercial</option> \
<option value="4">Exposição individual em galeria comercial</option> \
<option value="5">Residência</option> \
</select>';
// Hide the text inputs
$('#question'+qID+' .answer_cell_004 input[type="text"]').hide().parent().hide();
// Insert the select elements
$('#question'+qID+' .answer_cell_004').append(select1);
// Initially select an option if the question has already been answered
$('#question'+qID+' .answer_cell_004 input[type="text"]').each(function(i){
if($(this).val()) {
$(this).closest('td').find('.insertedSelect').val($(this).val());
}
});
// Listener on the dropdowns - insert selected values into hidden text input
$('.insertedSelect').change(function() {
$(this).closest('td').find('input[type="text"]').val($(this).val());
});
});
</script>
Hi, I'm trying to do the same thing with a three column array (want the first column to be a drop down) but this code doesn't seem to work for me. What am I doing wrong? (using the latest limesurvey version.)
Please specify your room requirements: <script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var qID = {qID};
// Define the select element (dropdown)
var select1 = '<select class="insertedSelect"> \
<option value="">-- Select Room Type --</option> \
<option value="1">Single</option> \
<option value="2">Twin</option> \
<option value="3">Disabled</option> \
</select>';
// Hide the text inputs
$('#question'+qID+' .answer_cell_001 input[type="text"]').hide();
// Insert the select elements
$('#question'+qID+' .answer_cell_001').append(select1);
// Initially select an option if the question has already been answered
$('#question'+qID+' .answer_cell_001 input[type="text"]').each(function(i){
if($(this).val()) {
$(this).closest('td').find('.insertedSelect').val($(this).val());
}
});
// Listener on the dropdowns - insert selected values into hidden text input
$('.insertedSelect').change(function() {
$(this).closest('td').find('input[type="text"]').val($(this).val());
});
});
</script>