Skip to content
This repository has been archived by the owner on Nov 8, 2017. It is now read-only.

Select First result from listing after press tab #334

Open
sunildeveloper07 opened this issue Jul 15, 2017 · 0 comments
Open

Select First result from listing after press tab #334

sunildeveloper07 opened this issue Jul 15, 2017 · 0 comments

Comments

@sunildeveloper07
Copy link

Hi Everyone

I want to find a solution like if i type only "zv" and press tab then first result from the listing will be select
and other details of the address should be save in hidden form. For now when i press tab then first address will replace with some another address. Thanks

This is my Code

`$(".auto-complete").geocomplete({
details: "#provider-signup,#edit-profile-provider-form",
types: ["geocode", "establishment"],
});

$(".auto-complete").on('blur',function () {
    
    $(".auto-complete").trigger("geocode");
    var firstResult = $(".pac-container .pac-item:first-child span:last-child").text();
    var geocoder = new google.maps.Geocoder();
    geocoder.geocode({"address":firstResult }, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            //console.log(results);
            var lat = results[0].geometry.location.lat(),
                lng = results[0].geometry.location.lng(),
                placeName = results[0].address_components[0].long_name;
                
               $("input[name='formatted_address']").val(results[0]['formatted_address']);
               $("input[name='lat']").val(lat);
               $("input[name='lng']").val(lng);
               $("input[name='locality']").val(placeName);
               $(".auto-complete").val(results[0]['formatted_address']);
               $(".auto-complete").trigger("geocode");
        }
    });
});`
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant