Dean Gibson Dean Gibson - 1 month ago 11
HTML Question

Disable/readonly select tag in html

How exactly can I go about making a select tag readonly. I've read that you can't set a select as readonly. I do that I can set it as disabled but... That is not an option. I would like the user to view the rest of the options in the select tag, but not be able to pick one of them..

Any ideas?

Answer

you can use disabled attribute.

for example.

<select >
  <option disabled="disabled" value="volvo">Volvo</option>
  <option disabled="disabled" value="saab">Saab</option>
  <option disabled="disabled" value="mercedes">Mercedes</option>
  <option disabled="disabled" value="audi">Audi</option>
</select>