I have an array like this:
var arr = ["1,JOAQUIN", "2,BERNARDINO", "3,MODOC", "4,MADERA"];
I would like to break it individually, for example
1 JOAQUIN
2 BERNARDINO
3 MODOC
4 MADERA
I am trying to do the following:
1. show the numbers (first index) in the jQuery UI
2. autocomplete list and their corresponding name in another text box.
Here is my code
var arr = ["1,JOAQUIN", "2,BERNARDINO", "3,MODOC", "4,MADERA"];
$('input').autocomplete({
source: json,
select: function(event, ui) {
var str = ui.item.value.split(',');
var lastIndex = str.length -1;
$('#two').val(str[lastIndex]);
}
});
However, I have a second point and am trying to find a solution to my first question.
Here is the JSFiddle
Share your suggestions and point me in the right direction.