Click here to Skip to main content
14,920,935 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
dear all,
i've created a JQuery UI Autocomplete in which the source is an array of label-value pairs.
i need to set the default selected item. i found a way to do that using the desired label,
but how can i do that if i have the VALUE instead of the LABEL?

code for setting default value using label string :

JavaScript
$("myAutoCom").autocomplete("search", "someLabel");
    var menu = $("myAutoCom").autocomplete("widget");
    $(menu[0].children[0]).click();


i have the value,not the label. how can i set selected item depending on value?
thanks in advance
Posted
Updated 29-Nov-14 21:51pm
v2

1 solution

since the source of my autocomplete is an array that contains all label-value pairs, and since i keep that array in a global variable, i just did the following:

searched THAT array for the given value and returned the corresponding label, then used that label to initialize the autocomplete using the code mentioned in the question.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900