How can I make a checkbox toggle its state when a user clicks on the text associated with it?Consider a checkbox that might occur, for example, on a software download form:
Note that the checkbox can be toggled by clicking on the box itself, but not by clicking on the associated text.
It is probably safe to say that most people who use computers on a regular basis have been generously exposed to the dialog boxes (a.k.a. "pop-up boxes") that appear in graphical user interfaces (GUIs) such as Microsoft Windows. Because of this, there is an unconscious tendency for users to rely on their experience with dialog box components as they interact with forms in a web browser.
One thing that annoys me about web forms is that the behavior of widgets (check boxes, push buttons, etc.) in web forms differs from the behavior of widgets in other dialog boxes.
For example, if the "Please keep me informed of updates." checkbox shown above were to appear in a normal dialog box -- and not in a web form -- then users would probably be able to toggle the checkbox's state not only by clicking on the box, but also by clicking on the text associated with and adjacent to the box.
Users who have a hard time aiming with the mouse -- and probably a few clumsy-fingered laptop touchpad users -- will definitely appreciate your extra effort.
Here is my solution to the problem:
toggle_checkboxis called. The parameter is a reference to the checkbox object.
toggle_checkboxis a relatively straight-forward function. It reads the boolean state of the checkbox and inverts it. (Because this function can be used for all checkboxes, the overhead of adding it to your web page is incurred only for the first checkbox.)
I used the tags
<font color=black> and
</font> to avoid tricking the user into believing that the text is a hyperlink to another document. This is, of course, a matter of preference and not strictly necessary.
If extending the functionality of form elements is this simple, why aren't more people doing it? It's probably because they never thought it was possible. But now you know better. So go forth, and make easier-to-use web forms!
30 Jan. 1997