Question

i have an problem with my autocomplete script:

If I search for example for "siegg" I get this information back

it

but, I don't what the full finded results written in the textbox

it

so, this is what i want:

it

Here are my javascript code:

$("#place_RegisterUser").autocomplete({
    source: function( request, response ) {
        $.ajax({
            url: 'webservice.php?method=GetAllAddressData&filter=' + $("#place_RegisterUser").val(),
            dataType: "json",
            data: {term: request.term},
            success: function(data) {
                response($.map(data.Values, function(item) {
                    return {
                        label: item.PlaceZIP + ", " + item.PlaceName + ", Bezirk " + item.CountyName,
                        PlaceZIP: item.PlaceZIP,
                        CountyName: item.CountyName,
                        FederalStateName: item.FederalStateName,
                        CountryName: item.CountryName
                        };
                }));
            }
        });
    },
    minLength: 2,
    select: function(event, ui) {
        $('#zipcode_RegisterUser').val(ui.item.PlaceZIP);
        $('#county_RegisterUser').val(ui.item.CountyName);
        $('#federalstate_RegisterUser').val(ui.item.FederalStateName);
        $('#country_RegisterUser').val(ui.item.CountryName);
    }
});
Was it helpful?

Solution

In your select callback add

$("#place_RegisterUser").val(ui.item.PlaceName);
return false;

http://api.jqueryui.com/autocomplete/#event-select The default action of the select event is to replace the text field's value with the value of the selected item.

return false from this event prevents the value from being updated. so you need to set it yourself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top