Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possible to have a readonly drop down menu?

Status
Not open for further replies.

bobrivers2003

Technical User
Oct 28, 2005
96
GB
<select name="asstName" readonly>
<option value="null" >-Select-</option>
<option value="Bill" >Bill</option>
<option value="Rob">Rob</option>
<option value="Fred">Fred</option>
</select>

I have a drop down menu and tried putting in the readonly attribute. But it doesn't work. Is there a solution to "lock" the drop down unless something happens? E.g. button pressed?

Many thanks
 
you can lock it through the attribute 'disabled'.

By the way, some doctypes require that the attribute has a value:
Code:
<select name="asstName" readonly="readonly">

<select name="asstName" disabled="disabled">

If you're unlocking it through JavaScript, be aware that some users surf with JS disabled, so you should provide server-side alternative to activate it (or leave it unlocked by default, and use an onload event to lock it).

---
Marcus
better questions get better answers - faq581-3339
accessible web design - zioncore.com
 
WOW!!!

Top stuff. Thank you very much for you help and advice :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top