[thelist] Radio button tab problem

James Aylard evolt at pixelwright.com
Wed Jul 30 16:41:54 CDT 2003

Joshua Olson wrote:

> Set the name attributes on all radio buttons to be unique from each
> other and set the tabindex to the order you'd like.  Have a set of
> hidden fields with the names of the original radio button groups.
> Then, within the onfocus of a radio button, set the value of the
> hidden field to the value of the selected radio button.  When the
> form submits it'll produce the same form variables as the original
> form except that it'll also have the extra radio buttons.  Depending
> on the naming convention you pick, you should be able to flush those
> out.

    While overcoming the default behavior of the browser may be a
professional challenge that stirs the creative juices, doing so usually
causes more problems than it solves. The level of complexity you suggest --
and the reliance on scripting to "correct" the browser's default behavior --
imo, far outweigh any benefits to this approach. I don't criticize the
attempt, per se, but I strongly discourage implementing it.
    The fact is that, without tinkering or tampering, all radio elements are
accessible in Internet Explorer via the keyboard using a combination of the
tab key and the arrow keys. While on some level it may seem counterintuitive
to have to switch from one key to the other in order to access the members
of a radio input group, it is important to remember that when you switch
between radio inputs you are not merely accessing them (as you would be with
text inputs, for instance), you are _selecting_ them -- making the currently
active radio input the selected option for the group.
    Using the arrow keys to switch between radio inputs is also standard
behavior within the Windows interface, which is likely the result of
extensive usability testing. If nothing else, it will be the expected
behavior by those who regularly use the keyboard to access form fields.
    I am a long-time advocate of the "exception" principle in web
development, and roll my eyes any time someone argues that you should
"never" implement a certain technology or approach. But likewise, I always
argue that exceptions should only be implemented when there is a clear
benefit to doing so that is difficult or impossible to achieve in a less
"exceptional" way, and only when the developer clearly understands the
possible side-effects. And I think a developer would be hard-pressed to
justify implementing the approach that you outline simply out of personal
discontent with the default behavior of the browser.

James Aylard
evolt at pixelwright.com

More information about the thelist mailing list