Welcome to WebmasterWorld Guest from

Forum Moderators: incrediBILL

Message Too Old, No Replies

<option disabled> makes option item disappear

9:40 am on Feb 17, 2007 (gmt 0)

Preferred Member

10+ Year Member

joined:Aug 20, 2004
votes: 0

Hello All -

I've got four dynamically generated select lists on a single page.

From time to time - depending on what's being pulled from the database - one or more of these lists will only show one item, like so:

<form name="foo">
<select name="bar" style="width:130px;">
<option value="S">S</option>

Sometimes, also depending on the state of the database, this single select item may be disabled, like so:

<form name="foo">
<select name="bar" style="width:130px;">
<option value="S" disabled>S</option>

The problem I'm having is that if there's only one item in the select list, and that single item is disabled, the single item doesn't appear.

Now, if I explicitly set the size on the select list to "2" (or more) then the item WILL show up. If I leave out the size attribute, or explicitly set it to "1" still no item.

The same thing happens in Opera and Netscape. Since this is happening in compliant browsers, I'm thinking that I'm the one who's mis-coding this attribute.

Can someone tell me how to solve this?

All assistance greatly appreciated,


2:11 am on Feb 28, 2007 (gmt 0)

Senior Member from CA 

WebmasterWorld Senior Member encyclo is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 31, 2003
votes: 6

Sorry it took so long to reply, neophyte.

When you say "disappear", do you mean that it does not show up as the default option in the drop-down box, like it does when the item is not disabled?

If so, this is logical in that when the item is not disabled and it is the only option, the browser will select it by default. However if the item is disabled, there is no appropriate candidate for selection - hence the blank space and the disabled option below in the drop-down.

Note that IE doesn't properly support the

attribute on the

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members