Shaun Mccran

My digital playground

13
N
O
V
2008

Non Selectable options in a drop down

Its been a while since I learned any new HTML, but today I did.

Recently I was creating a list of two separate data sets, a primary list of high level countries, and a secondary list of less prominent countries.

So to separate the data I thought I'd stick an:

view plain print about
1<option disabled="true">-----</option>

But that doesn't work! It still leaves your option as a selectable index.

Instead there is a tag, the 'optgroup' code. It turns out that you can wrap your group of options with this tag, and it inserts an unselectable option into the list!

view plain print about
1<select name="country">
2 <optgroup label="-------------------">
3 <option value="1">1</option>
4 <option value="2">2</option>
5 <option value="3">3</option>
6 </optgroup>
7 <optgroup label="--------------------">
8 <option value="A">A</option>
9 <option value="B">B</option>
10 <option value="C">C</option>
11 </optgroup>
12</select>

TweetBacks
Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Simon Silvestor Clarke's Gravatar Projects and tasks of the students are measured and calculated in terms and connotations of the studies http://www.ukbesteessays.com/ and theories of the subjects. It is very important and pivotal for the certain and particular goals.
# Posted By Simon Silvestor Clarke | 03/11/2015 23:33

_UNKNOWNTRANSLATION_