Hello,
I have a short text question where I ask for the address of the respondent (name of the municipality).
As I have a long list of municipalities (about 8000) , I have created a CSV file (according to:
stackoverflow.com/questions/27803669/lim...uto-complete-feature
and
www.limesurvey.org/manual/Workarounds:_M...ime_using_Javascript
).
I have two problems about the question:
1. The names of the municipalities are not shown correctly in the case they contain special codes for Italy (è, ì, ù, à, ò), i.e. "Agliè" becomes "Agli" + a strange character and this happens also after adding charset=iso-8859-1 in the script.
The script attached to the question is:
<script type="text/javascript"; charset=iso-8859-1"; src="{TEMPLATEURL}jquery.csv-0.71.js"></script><script>
var url = "{TEMPLATEURL}comun.csv";
$(function() {
var qID = {QID};
var comuni = new Array();
$.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
});
// console.log(data);
});
});</script>Address:
I enclose here the survey code:
and the csv file:
File Attachment:
File Name:
comun.csv
File Size:73.34 KB
2. Is there a way to save in a new variable (possibly not visible to the respondent) the code of the municipality, instead of the name? In this case the csv file (I enclose here a sample
File Attachment:
File Name:
comcode.csv
File Size:147.43 KB
) should be something like:
municipality1 code1
municipality2 code2
municipality3 code3
and so on
Kind regards,
Elo
P.S. I use LS 2.06+ Build 151215