TarekRaafat / autoComplete.js

Simple autocomplete pure vanilla Javascript library.
https://tarekraafat.github.io/autoComplete.js
Apache License 2.0
3.93k stars 236 forks source link

Example how to set initial value #350

Open annashamray opened 2 years ago

annashamray commented 2 years ago

I'd like to create an autocomplete with prefilled initial value, but I can't find which configuration parameter can help me. Could you please provide an example how to do it, please?

TarekRaafat commented 2 years ago

Hello @annashamray,

You can add the below line inside the data.src function.

// Prefill input field with the string "Pizza"
document.getElementById("autoComplete").value = "Pizza";

Please try and let me know how it goes.

Cheers! :)