Back



This example shows a single-select autocomplete with a clear button.
Single-select (Button)

Source of exampleCopy to clipboard


const productAutocomplete = new AvalynxAutocomplete('#productSearch', {
    fetchData: async (query) => {
        const response = await fetch('php/result.php?type=products&search=' + encodeURIComponent(query));
        return await response.json();
    },
    maxItems: 5,
    clearStyle: 'button',
    onChange: (key, value) => console.log('Product:', key, value)
}, {
    placeholder: 'Search product...',
    noResults: 'No products found'
});
	
AvalynxAutocomplete on GitHub Avalynx on GitHub