- From: Jesse McCarthy <whatwg-2010-04@jessemccarthy.net>
- Date: Tue, 10 Aug 2010 11:57:38 -0400
I'm not sure what the right solution is, but here's my two cents. I consider it highly desirable to have some way to differentiate between SELECT values explicitly selected by the user and values that were selected by default and unchanged by the user. For that reason I've commonly included "Choose one" options: <option value="">Choose one</option> > I can think of lots of places where an empty string is in-fact very useful > for a select element, such as filters on search results forms I also see Ashley's point because I've done that too. E.g. <select name="gender"> <option value="">Doesn't matter</option> <option value="M">Male</option> <option value="F">Female</option> </select> However, I think in those cases I could substitute some other value for empty string (e.g. "*" in this case) that would communicate the necessary information to the server-side logic. > If you need to do that, then maybe use radio buttons instead. I don't see that as a practical alternative in many cases: radio buttons take up a lot more space. Even in the gender example I gave, using radio buttons instead would have a detrimental effect on the layout of the particular form I took the example from. And when there are more options it makes a huge difference. Radio buttons could be very unwieldy where a SELECT works well. Jesse ----- Original Message ----- > Date: Tue, 10 Aug 2010 10:35:53 +0100 > From: Ashley Sheridan <ash at ashleysheridan.co.uk> > > If you receive an empty text box then a required element works to > validate against empty input. As you produce the input for the select > list, it's pretty stupid to say that it shouldn't have an empty string > for a value because you put it there. > > I can think of lots of places where an empty string is in-fact very > useful for a select element, such as filters on search results forms, > but if there's any places that I want a value, then I don't leave empty > elements lying around. If you need to do that, then maybe use radio > buttons instead. > > Thanks, > Ash > http://www.ashleysheridan.co.uk > >
Received on Tuesday, 10 August 2010 08:57:38 UTC