So i want to make an input field, which would refresh everytime the user type something, without having to press a button or enter.
I already know about the 'oninput' event like this :
<input type='text' oninput='refresh'>
And in my script.js :
function refresh()
{
console.log('refreshed!');
}
The problem is that this fire an event every time I just write or delete one letter. And as I will have to make SQL queries to refresh, I don't think it's very efficient to make queries for every change.
So my idea was:
- to find a way to fire the
oninput
event every 1 second, but this would feel a bit laggy; - I don't know if this exists but to only fire an event when the user stop typing.
So, do you know any way I could improve my search bar?