[thelist] "onchange" event on checkbox and YUI

Lee Kowalkowski lee.kowalkowski at googlemail.com
Tue Jul 28 02:35:30 CDT 2009

2009/7/27 Bill Moseley <moseley at hank.org>:
> This is the famous IE problem where onchange on a checkbox doesn't
> fire until you leave the element.
> I have a checkbox and an associated <label>.  When checked I simply
> want to display an additional element (additional form elements),
> and likewise hide when unchecked.
> YAHOO.util.Event.on(
>     checkbox_element,
>    'change',
>     function() { sub_el.style.display = checkbox_element.checked ?
> 'block' : 'none' }
>  );
> But, IE won't trigger the event until focus moves from the checkbox.
> Keep in mind that the check box can be selected (and de-selected) by
> clicking on the label, but also by tabbing to the
> checkbox element and hitting the space bar.

Reading between the lines, this sounds like you don't want to use
onclick.  However, onclick will also fire in those scenarios.  The
onclick event is device-independent on form elements and links, just
not on other elements.

I've been in workshops where authors don't want to use 'click' in
their instructional content because it implies use of the mouse. I
understand that, but feel it's reasonable to use 'click' in the
context of a cursor gesture, keyboard users would understand.  Anyway,
the authors decided to go with 'select', I'm still tempted to give
their help desk a ring - "I'm selecting your links, nothings


More information about the thelist mailing list