Welcome to WebmasterWorld Guest from 54.226.25.231

Forum Moderators: incrediBILL

Message Too Old, No Replies

<option disabled> makes option item disappear

     

neophyte

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

10+ Year Member



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>
</select>
</form>

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>
</select>
</form>

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,

Neophyte

encyclo

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

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



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

disabled
attribute on the
option
element.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month