Autocomplete select Event to Show Record Details

This example extends the database source demo. Suggestions come from the student table; when the user selects one, the visible input keeps the student's name and a second endpoint loads the record details.

Select a student to show details.

Autocomplete with a select Event Top ↑

$( "#t1" ).autocomplete({
    source: function ( request, response ) {
        $.getJSON(
            "autocomplete-demo1-dtl.php",
            { term: request.term }
        )
        .done( response )
        .fail( function () {
            response( [] );
        } );
    },

    select: function ( event, ui ) {
        event.preventDefault();

        this.value = ui.item.label;

        $( "#d1" ).load(
            "autocomplete-demo1-dtl-db.php",
            { id: ui.item.value }
        );

        return false;
    }
});

Why Use label and value Separately? Top ↑

  • label is human-readable text shown in the suggestion menu and input.
  • value carries the record ID used for the database detail request.

Video: Autocomplete Details from a Database

For the full location/PIN-code example, see Autocomplete Search.





plus2net.com






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer