I am trying to add value to the text box of the drop down <select>
tag in HTML with JavaScript. This is my code:
function disableTip() {
document.getElementById('cars').value = 'Hello';
}
<label for="cars">Choose a car:</label>
<select name="cars" id="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
<button onclick="disableTip()">Click me</button>
When i click the button the textbox becomes empty doesn't write "Hello". Any idea what is wrong with my code?
Thanks in advance.