Disable/readonly select tag in html

user818700 picture user818700 · Nov 29, 2011 · Viewed 73.5k times · Source

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

Muhammad Saifuddin picture Muhammad Saifuddin · Nov 29, 2011

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>