GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
jquery autocomplete postalcode  XML
Forum Index -> General
Author Message
Hydro



Joined: 16/04/2013 00:06:40
Messages: 1
Offline

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 ?
 
Forum Index -> General
Go to:   
Powered by JForum 2.1.5 © JForum Team