- Posts: 44
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:complete',function() { var qID = {QID}; var inputNum = 4; // Define the select element (dropdown) var prov1 = '<select id="prov1" class="form-control">\ <option value="">--Choose education level--</option>\ <option value="1">Primary education</option>\ <option value="2">Pre-vocational secondary education (VMBO)</option>\ <option value="3">Senior general secondary education (HAVO) substructure (Year 1-3)</option>\ <option value="4">Senior general secondary education (HAVO) (Year 4-5)</option>\ <option value="5">Senior general secondary education (HAVO) (Year 1-5)</option>\ <option value="6">Pre-university education (VWO) substructure (Year 1-3)</option>\ <option value="7">Pre-university education (VWO) (Year 4-6) </option>\ <option value="7">Pre-university education (VWO) (Year 1-6) </option>\ <option value="8">MBO Level 1</option>\ <option value="9">MBO level 2-4</option>\ <option value="10">Higher professional education (HBO) bachelor</option>\ <option value="11">Higher professional education (HBO) master</option>\ <option value="12">University education (WO) bachelor</option>\ <option value="13">University education (WO) master</option>\ <option value="14">University education (WO) doctor</option>\ <option value="15">Other education level</option>\ </select>'; // Hide the text input $('#question'+qID+' .question-item:eq('+(inputNum-1)+') input[type="text"]').hide(); // Insert the select elements if($('#question'+qID+' .question-item:eq('+(inputNum-1)+') select').length == 0) { $('#question'+qID+' .question-item:eq('+(inputNum-1)+') input[type="text"]').before(prov1); } // Initially select an option if the question has already been answered $('#question'+qID+' select').each(function(i) { if($.trim($(this).next('input[type="text"]').val()) != '') { $(this).val($.trim($(this).next('input[type="text"]').val())); } }); // Listener on the dropdowns - insert selected values into hidden text input $('#question'+qID+' select').change(function() { var thisInput = $(this).next('input[type="text"]'); $(thisInput).val($(this).val()); checkconditions($(thisInput).attr('value'), $(thisInput).attr('name'), 'text'); }); // Some styles $('#question'+qID+' select').css({ 'margin':'0.3em 0 0 0' }); }); </script>
Because event is attached to .select-item select or .dropdown-item selecttpartner wrote: The problem is that Expression Manager is not being fired by the "change" or "keyup" events (I don't know why).
$('#question'+qID+' .question-item:eq('+(inputNum-1)+') input[type="text"]').hide().closest(".answer-item").addClass("dropdown-item");