Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140705

Javascript how to make auto suggest results appear after entering 3 characters

$
0
0

I have an array with cars like this:

[
  {"name" : "Audi"},
  {"name" : "BMW"},
  {"name" : "Mercedes"}, 
  {"name" : "VW"},
  {"name" : "Fiat"},
  {"name" : "Hyundai"},
  {"name" : "Opel"},
  ...and many many more
]

now I have an input field, where users can search for their desired car but I want to include some auto-suggest. So far I have made this

<input type="text" @input="filterCars" v-model="search" />


filterSkills() {
  this.filterCars = this.cars.filter(car => {
    return car.name.toLowerCase().includes(this.search.toLowerCase());
  });
}

which actually works fine, but I want to make the matching results appear, after the user has entered 3 characters - for example, when I type 'Aud' - Audi will appear as suggestion - how can I do that?


Viewing all articles
Browse latest Browse all 140705

Latest Images

Trending Articles



Latest Images