Detecting status change in a checkbox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • waleed

    #1

    Detecting status change in a checkbox

    I'm not really good with javascript, basically what I'm trying to do
    is that I want to be able to handle when the status of a checkbox is
    changed (i.e. checked or unchecked), I see everybody is using onclick
    but I wonder if this is the correct approach, what if a user changes
    the status of the checkbox using the keyboard, will onclick be
    triggered? I know I might sound a little picky here but I believe
    those people who created DHTML must've thought about this, right?

    Sorry if I posted the question in the wrong group, I couldn't find a
    good group for DHTML, I assume many people post questions about DHTML
    here as javascript and DHTML are very related, anyway a post in the
    wrong group is still better than all this spam I see everywhere here!
  • waleed

    #2
    Re: Detecting status change in a checkbox

    Never mind guys, I just realized that onclick is also triggered when
    the user checks/unchecks the checkbox using the keyboard ...

    Comment

    • Steve Swift

      #3
      Re: Detecting status change in a checkbox

      waleed wrote:
      I'm not really good with javascript, basically what I'm trying to do
      is that I want to be able to handle when the status of a checkbox is
      changed (i.e. checked or unchecked), I see everybody is using onclick
      but I wonder if this is the correct approach, what if a user changes
      the status of the checkbox using the keyboard, will onclick be
      triggered?
      I think that onChange is what you want. I was tinkering with some
      onChange code for RADIO buttons recently, and discovered that onChange
      seems to trigger for radio buttons only when they change from unchecked
      to checked. There is some sense in this, otherwise you'd often get two
      events each time a button was changed (the other one coming from the
      button which got unchecked).

      --
      Steve Swift
      http://www.swiftys.org.uk/swifty.html

      Comment

      Working...