View Single Post
 
Old May 19th, 2004, 07:32 AM
Daniel Walker Daniel Walker is offline
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 256
Thanks: 0
Thanked 0 Times in 0 Posts
Default

From a usablity point of view, may I suggest using a pair of radio buttons, instead? Radio buttons are used in sets, identified by their sharing the same name attribute and only one selection is possible. So you'd have something like:

Would you describe yourself as an Amoeboid Zingat-Ularian?<br />
Yes<input type="radio" name="rad" value="yes" id="radio1">
No<input type="radio" name="rad" value="no" id="radio1">

Whichever value is selected is passed to your script upon submission. The advantage is that the user can see the options available to them without having to interact with the form.

Without digressing too far into a discussion about HTML, you can improve the accessibility further by wrapping them in labels (this is a great help to Amoeboid Zingat-Ularians, who have very short tentacles - as anyone who's met one will tell you - and they thus find using a conventional mouse very difficult). Your radio buttons now look like this:

<fieldset>
<legend>Would you describe yourself as an Amoeboid Zingat-Ularian?</legend>
<div><label for="radio1"><input type="radio" name="rad"
value="yes" id="radio1">Yes</label></div>
<div><label for="radio2"><input type="radio" name="rad"
value="no" id="radio2" checked>No</label></div>
</fieldset>

Note the use of the 'id' to identify the actual button, and the 'name' attribute to identify the set of controls, as a group. Now our tentically-challenged Amoeboid Zingat-Ularians need only hit the appropriate text, instead of the actual control, to switch the values. The text can be anywhere on the page, as well.

This applies to IE4+, Netscape6+ and all versions of Mozilla Opera 5+, and has no adverse affects for browsers that don't support the <label> element.