- Posts: 58
- Thank you received: 9
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { var qID = {QID}; var nextQuestion = $('#question'+qID).nextAll('.text-short'); var url = "{TEMPLATEURL}comcode.csv"; var comuni = []; // Hide the next question //nextQuestion.hide(); $.get(url,function(data){ // Convert CSV contents to an array of arrays fullArray = $.csv.toArrays(data); // Load the data array $(fullArray).each(function(i, item){ comuni.push(item[0]); }); // Initialise the autocomplete plugin $('#question'+qID+' input.text').autocomplete({ source: comuni, select: function(event, ui) { // Load the hidden "Code" question var thisValue = ui.item.value; $(fullArray).each(function(i, item){ if(item[0] == thisValue) { $('input.text', nextQuestion).val(item[1]); } }); } }); }); }); </script>
$('#question'+qID).nextAll('.text-short:eq(0)');