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): Choose a browser... Netscape Navigator 4.x or higher Netscape Navigator 3.x Netscape Navigator 2.x Netscape Navigator 1.x Microsoft Internet Explorer 4.x or higher Microsoft Internet Explorer 3.x Microsoft Internet Explorer 2.x Microsoft Internet Explorer 1.x Opera 3.x or higher Opera 2.x Other
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>
Remember Me
Powered by: newtelligence dasBlog 1.9.6264.0
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.
© Copyright 2008, John Batdorf
E-mail