Reputation: 1674
I borrowed the code from http://jqueryui.com/demos/autocomplete/#combobox but don't know how to get the value of the selected item.
Hoping for a simple straight answer rather than reading their docs for the next 2 hours.
Upvotes: 1
Views: 12712
Reputation: 619
first set id of textbox and then get value of that textbox and match it with text of option of dropdown, if option's text match then get its value.you can see example here in jsfiddle
this.input = $("<input>")
.appendTo(this.wrapper)
.val(value)
.attr('placeholder', "Enter Type...")
.attr("title", "")
// Set Id of Input Type Text
.attr('id', 'Mach')
.addClass("custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left")
.autocomplete({
delay: 0,
minLength: 0,
source: $.proxy(this, "_source")
})
Upvotes: 0
Reputation: 757
you can use $('#comboname').combobox('getValue')
to get the value.
for more information and demo, you can see here http://www.jeasyui.com/demo/main/index.php?
Upvotes: 0
Reputation: 149
in Easy UI combo box:
to get current value
$('#combobox').combobox('getValue')
to get current string
$('#combobox').combobox('getText')
hope this helps.
Upvotes: 2
Reputation: 1
$(this).combobox({ selected: function (event, obj) {
console.log(obj.item.value) // log val
window.location.href = obj.item.value; // if you are using a url then give this a go
} });
This might make things a bit simpler to understand.
Upvotes: 0
Reputation: 237
If your are using an 'input' element, this is how I got it to work.
<input type="text" id="comboBox" />
JavaScript
$("#comboBox option:selected").val()
That will return the value selected.
Upvotes: 1
Reputation: 6825
$('#combobox').val() might do the trick
ok, that's not correct. do it this way:
$( "#combobox" ).autocomplete({
select: function(event, ui) { ... }
});
in there do a console.log($(ui).val()) or something like it
then you should be able to do either: $('#combobox').text() or .val() to get its content.
Upvotes: 3