DEV Community

Discussion on: 👨‍💻 Make AutoComplete Input Box In Pure Javascript 🔥🔥

Collapse
 
manikantapamarthi profile image
Manikanta Nagaraju Pamarthi

I think your just filtering the names array, How to select the name from the list?

Collapse
 
sharmakushal profile image
Kushal sharma

You can easily do this by adding the onclick function to the li element and getting its index and get the respective value from the array for that index and saving to your variable

Collapse
 
xuchunyang profile image
徐春阳

Selecting with mouse seems easy. Most autocomplete interface supports keyboard up/down arrow keys, we need maintain the current selection state somewhere, it does not seem easy to me (I'm a beginner to webdev).

Collapse
 
manikantapamarthi profile image
Manikanta Nagaraju Pamarthi

Yes, I tried with some dynamic data coming from the DB, but on click, is not working. May be because of element rendering problem.

anyhow I fixed my problem in my own way.

Thank you.