Rasmus
Rasmus

Reputation: 83

Set AutoCompleteInput to suggest list of words

In my Vue project I found that setting the id to "autocompleteInput" made it suggest prevously typed words then the input field is focused:

                <input
                  id="autocompleteInput"
                />

But how do I make it suggest a list of words by default? E.g. how to give the autocompleteInput a list like this: ["Germany", "France", "Spain"] and then it suggests those?

I dont know why setting input id to "autocompleteInput" gives previously typed suggestions but it does.

Upvotes: 0

Views: 47

Answers (1)

Rasmus
Rasmus

Reputation: 83

Solved: Found this simple solution:

              <input
                  list="browsers"
                />
                <datalist id="browsers">
                  <option value="Chrome"></option>
                  <option value="Firefox"></option>
                </datalist>

Upvotes: 0

Related Questions