Search code examples
htmlselectreadonly

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?


Solution

  • 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>