Splitting an array before adding to combo list
I have a JSON object that returns several key value pairs. One of which is
a Languages key and this contains comma separated values e.g "English,
Hindi,French" etc
I'm trying to split the array before adding it to a combo list, but
everything I try fails. Can anybody help, please?
$('#combolist-languages').html(function () {
var ret = '<option value="-1" selected>Select
language_</option>',
u = user.slice(),
arr = [];
(function get() {
if (u.length) {
var v = u.shift();
if ($.inArray(v.Languages, arr) == -1) {
arr.push(v.Languages);
ret += '<option value="">' + v.Languages +
'</option>';
}
get();
}
}());
return ret;
});
I'm just not sure where to put the split function. Thanks!
No comments:
Post a Comment