Write JS autocomplete (given index)