By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,850 Members | 1,962 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,850 IT Pros & Developers. It's quick & easy.

Detecting status change in a checkbox

P: n/a
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!
Sep 29 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Never mind guys, I just realized that onclick is also triggered when
the user checks/unchecks the checkbox using the keyboard ...
Sep 29 '08 #2

P: n/a
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
http://www.ringers.org.uk
Sep 29 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.