How to implement an input, when clicked, a drop-down list would appear with a choice of operator.

I found this solution using database:

<input name="city" list="cities" /> <datalist id="cities"> <option value="Naples" /> <option value="London" /> <option value="Berlin" /> <option value="New York" /> <option value="Frattamaggiore" /> </datalist> 

But this method is more suitable for autocomplete, and I need to just be able to select the operator code and he signed up for input. Can anyone have a ready-made solution or some kind of library?

    1 answer 1

     $('select#cities').on('change', function() { $('input[name="city"]').val(this.value); }); 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input name="city" /> <select id="cities"> <option value="Naples">Naples</option> <option value="London">London</option> <option value="Berlin">Berlin</option> <option value="New York">New York</option> <option value="Frattamaggiore">Frattamaggiore</option> </select> 

    • @Regent thanks for the comment. updated the answer - Cheg