Reputation: 3189
Simple text field change after jquery auto complete select event. I want to split the data and display it in other text fields. I am trying this. This doesn't change any values at all. What do I need to change here?
$(function() {
$("#term").autocomplete({
source: function (request, response) {
$.post("/users/search", request, response);
},
minLength: 2,
select: function(event, ui){
$('#div2').html(ui.item.value); #doesn't populate with new text.
document.getElementById('#found').value="test"; #for test
} #doesn't populate with new text.
#I want selected data to go here in the 'found' element id
});
});
Ruby/html -
<%= text_field_tag :found, nil, :maxlength => 11, :size => 20%>
<input id="found" maxlength="11" name="found" size="20" type="text" />
Upvotes: 3
Views: 4225
Reputation: 11598
Change this line:
document.getElementById('#found').value="test"; #for test
to:
$('#found').val('test');
Upvotes: 4