Hi
I use jquery autocomplete and i want to write zipcode in input and city name appear on a second input.
But i don't achieve to keep postalcode on the first input.
Code:
$(function() {
function log( message ) {
$( "<div>" ).text( message ).prependTo( "#log" );
$( "#log" ).scrollTop( 0 );
}
$( "#city" ).autocomplete({
source: function( request, response ) {
$.ajax({
url: "http://ws.geonames.org/searchJSON?&country=FR",
dataType: "jsonp",
data: {
featureClass: "P",
style: "full",
maxRows: 12,
name_startsWith: request.term
},
success: function( data ) {
response( $.map( data.geonames, function( item ) {
return {
label: item.name,
value: item.postalCode
}
}));
}
});
},
minLength: 2,
select: function( event, ui ) {
log( ui.item ?
"" + ui.item.label :
"" + this.value);
},
open: function() {
$( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
},
close: function() {
$( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
}
});
});
With "value: item.postalCode" i've got city name in both input. If i try item.adminCode3 it works but not postalCode.
I use french city. Somebody know how to do that ?