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

Select First result from listing after press tab #334

@sunildeveloper07

Description

@sunildeveloper07

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");
        }
    });
});`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions