javascript - Ajax Autocomplete for jQuery and Extra Data -
looking guidance using ajax automplete jquery (http://www.devbridge.com/projects/autocomplete/jquery). i've been able implement retrieve list of schools when user types, include city , state information prompt. example can found here:
http://www.keuka.edu/pete/inquiry (use "high school name" field , type in local high school)
i've programmed generate data, i'm including span in suggestion field, , it's populating information in textbox.
does have insights how include helpful information have name show in textbox when user selects suggestion?
thanks!
you can use onselect replace textbox value data.
from example provided @ autocomplete project. added 1 line.
$('#autocomplete-ajax').autocomplete({ lookup: countriesarray, lookupfilter: function(suggestion, originalquery, querylowercase) { var re = new regexp('\\b' + $.autocomplete.utils.escaperegexchars(querylowercase), 'gi'); return re.test(suggestion.value); }, onselect: function(suggestion) { $('input#autocomplete-ajax').val(suggestion.data);// replace data $('#selction-ajax').html('you selected: ' + suggestion.value + ', ' + suggestion.data); } }); the line want bring attention is:
$('input#autocomplete-ajax').val(suggestion.data);// replace data
you can strip span out of chosen value.
Comments
Post a Comment