How to get ids of multiple values in autocomplete

Here I'm fetching multiple values and now i have to get the ids(keys) of these values.
for one im able to get by this code in javascript

html code
<input id="abc" type="text"/>

Javascript code

 var autocompleteObj = $("#abc").data("ejAutocomplete");
     var x=autocompleteObj.getSelectedItems()[0].id,

but when im fetching multiple values im not getting how to do it.

1 Reply

AP Arun Palaniyandi Syncfusion Team April 6, 2018 12:53 PM UTC

Hi Shalini, 
 
Thanks for contacting Syncfusion support. 
 
We have checked our shared code snippets and hence in order to get the selected items id we suggest you to use the for loop to get all the ids of the selected values.  Please find the below code snippets. 
 
 
 
 
<script> 
 
function myClick() { 
 
var autocompleteObj = $("#abc").data("ejAutocomplete"); 
 
var selecteditems = autocompleteObj.getSelectedItems(); // get the selecteditems 
 
var len = selecteditems.length; 
 
var selectedata = [] 
 
for (var i = 0; i < len; i++) { // use for loop 
 
  selectedata.push(selecteditems[i].id); // take the values and then store in a array variable and use this value 
 
} 
alert(selectedata);  
 
} 
 
</script> 
 
 
Please find the sample below for your reference. 
 
 
API Link: 
 
 
Please let us know if you need any further assistance. 
       
Regards,
Arun P.
 


Loader.
Up arrow icon