views:

45

answers:

2

I need a way to have a multi-select box that has a disabled element. I want the box to look like:

All

-----or-----

option 1

option 2

with the "----or----" not being able to be selected. So far my code is pretty simple:

<select multiple size="4" >
  <option value="0">All</option>
  <option value="1">----or----</option>
  <option value="2">option 1</option>
  <option value="3">option 2</option>
</select>

But as of yet I have been unable to get the '----or----" disabled or unselectable. I've looked around and I'm not sure there is an HTML attribute that will disable it, but I'm really not sure and I'm also not sure this is the best way to present this option. Any help you can offer is greatly appreciated!

+2  A: 

Maybe take a look at the optgroup element ?

Scott Evernden
+2  A: 
<select multiple size="4" >
  <option value="0">All</option>
  <optgroup label="----or----"></optgroup>
  <option value="2">option 1</option>
  <option value="3">option 2</option>
</select>
dekomote
That did it, thank you! Is there a way to edit how the optgroup displays though? I'm not sure bold and itallic will work and using the inline 'style' attribute doesn't seem to do anything. I'm developing in/for IE7 btw if that makes a difference
Drew
Unfortunately no. You can't style the bold thing, but you can change text color, font etc.
dekomote