Why you want to have a text field, you can simply use select tag
<label for="cars">Choose a car:</label>
<select name="cars" id="cars" oninput="myFunc(this)">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
This will create a dropdown. You can attach the value to a div to show it
function myFunc(selected){
//you can replace the divId below by your div's id
document.getElementById("divId").innerHTML=selected.value;
}
Or you can use input type=”radio”
CLICK HERE to find out more related problems solutions.