Friday, October 21, 2005
« AdRotator Component for .NET | Main | Can you pass 8th grade math? »

Ok this is another one of those things that's probably been around for quite a while, but I had never seen or knew about.
How often have you wanted to created a select list (drop down) with category headers, but you don't want someone to selcect the category header itself? Well you'd have to assign a value of  -1 or 0 or something, and then perform some sort of validation to ensure the user had not chosen the 'invalid' item.

I found this on the Apple site, and although I need to do some more research, it appears to be part of the HTML 4.0 spec, and so far it works in every browser I've tried it in.

Here is the dropdown (it does not do anything):

And here's the script:
   <SELECT NAME="browser">
    <option label="-1" selected>Choose a browser...</option>
    <OPTGROUP LABEL="Netscape Navigator">
     <OPTION LABEL="4.x or higher">
      Netscape Navigator 4.x or higher
     </OPTION>
     <OPTION LABEL="3.x">Netscape Navigator 3.x</OPTION>
     <OPTION LABEL="2.x">Netscape Navigator 2.x</OPTION>
     <OPTION LABEL="1.x">Netscape Navigator 1.x</OPTION>
    </OPTGROUP>
    <OPTGROUP LABEL="Microsoft Internet Explorer">
     <OPTION LABEL="4.x or higher">
      Microsoft Internet Explorer 4.x or higher
     </OPTION>
     <OPTION LABEL="3.x">Microsoft Internet Explorer 3.x</OPTION>
     <OPTION LABEL="2.x">Microsoft Internet Explorer 2.x</OPTION>
     <OPTION LABEL="1.x">Microsoft Internet Explorer 1.x</OPTION>
    </OPTGROUP>
    <OPTGROUP LABEL="Opera">
     <OPTION LABEL="3.x or higher">Opera 3.x or higher</OPTION>
     <OPTION LABEL="2.x">Opera 2.x</OPTION>
     <OPTION>Other</OPTION>
    </OPTGROUP>
   </SELECT>

Friday, October 21, 2005 10:50:17 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  |  Related posts: