jquery ui autocomplete get value of selected option
14,359
var value = $("#the_input_ID").val();
if you want to be notified when a value is selected you can use something along the lines like this:
var selected_value;
$( "#your_input_id" ).autocomplete({
select: function(event, ui) {
selected_value = $(ui).val();
}
});
Author by
Julian
Updated on June 04, 2022Comments
-
Julian almost 2 years
How can i get the value of the selected option in the menu that is created by jquery ui autocomplete into a variable?
-
Julian about 11 yearsi want to get the value without getting it by the field in that jquery ui it writes.
-
Hugo Alves about 11 years@Julian can you be more explicite. Do you want to be notified when the user select something or something completely different?
-
Julian about 11 yearsmy problem is that i want to get the value of the selected option of the user without using the field in which is entered the value. I want to do some thinks with the selected value and then write it into 3 different fields.
-
Hugo Alves about 11 years@Julian i've updated my question, is this what you want. this way the selected function is called when the user selects something and that value is saved in the
selected_value
-
Julian about 11 yearsok its so: i want to get the value that the user selects because the answer from the server that uses autocomplete have a lot of options and i want have the option that the user choses. I dont want to use the field because if i first use the value that is written in the field and i then change the value that is written in the field the user of the website see this(that the value changes). Because that i want to find another straighter way to get the value and than i dont want to write the value with jquery ui in the field. Sorry for my bad english :S