BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
Hi Kovacs,
Thanks for using Syncfusion products.
Query: I use javascript controls but I don't know how I can get autocompletetextbox field "index" value when submit button click
We would like to inform you that, there is no inbuilt method to get the “index (i.e., key/id)” of Autocomplete value. In autocomplete we can type any values, so there may not be an “id” associated with each values. But, if the Autocomplete value has “id” associated with it means, we can get it in the “focusout” event of the Autocomplete. To achieve your requirement, in the “focusout” event, we need to compare the value in the Autocomplete textbox with each values in the data source. If both the values matches means, then we can get the “id” associated with it. Please refer the below code,
[Script]
function onFocusOut(args) { // Value in the Autocomplete textbox is obtained from args var AutocompleteValue = args.value; //for loop that iterates for each object in the datasource "states" for (var data = 0; data < states.length; data++) { //check whether the value in the autocomplete textbox matches with any of the value in autocomplete datasource if (states[data].countryName === AutocompleteValue){ //Get the "index" of the matched value and store it in a variable uniqueKey = states[data].index; break; } } } |
For your convenience, we have attached a simple sample in the following location to showcase you requirement.
Sample Location: Get autocomplete key
Please check with the provided sample. If you need further assistance, please get back to us we will assist you gladly.
Regards,
HariKrishnan