K
K
KitCat122021-06-11 09:26:00
JavaScript
KitCat12, 2021-06-11 09:26:00

How to add suggested options as you type in input?

There is such an input

<input type="text" class="test_text" placeholder="Test" autofocus/>

And there is, let's say, such a list How to make it so that when entering text into the input, if there is a match with the value from the list, then a hint is displayed that you can click on and it would substitute the value in the input automatically. How do we let here
['123', '456', '789']


60c301f61416c770622025.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim, 2021-06-11
@KitCat12

In a simple form - htmlbook.ru/html/datalist
In general, such things are usually implemented like this: make an ajax request as you type with some debounce effect, and render custom autocompletes.
For example here: autocomplete-js.com
Or here https://tarekraafat.github.io/autoComplete.js/#/
Or here https://github.com/algolia/autocomplete

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question