Answers for "disable option in select html"

2

html option disabled

<label for="cars">Choose a car:</label>
<select name="cars" id="cars">
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
    <option value="n/a" disabled>unavailable</option>
</select> 
<select name="color" id="color">
	<option value="" selected disabled hidden>Choose color...</option>
    <option value="R">Red</option>
    <option value="B">Blue</option>
</select>
Posted by: Guest on March-20-2021
1

howt to disable a select tag using js

document.getElementById("one").onchange = function () {
  document.getElementById("two").setAttribute("disabled", "disabled");
  if (this.value == 'car')
    document.getElementById("two").removeAttribute("disabled");
};
Posted by: Guest on November-27-2020

Code answers related to "disable option in select html"

Browse Popular Code Answers by Language