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

input checkbox onchange not working on IE7

P: n/a
I am finding that <input type="checkbox" onchange="alert('test')"></input>
does not seem to work properly on IE7.

http://www.aarongray.org/Test/JavaScript/checkbox.html

It works fine on FF and Google Chrome.

Any suggestions ?

Many thanks in advance,

Aaron
Oct 30 '08 #1
Share this Question
Share on Google+
7 Replies


P: n/a
On Oct 30, 3:17*pm, "Aaron Gray" <ang.use...@gmail.comwrote:
I am finding that <input type="checkbox" onchange="alert('test')"></input>
does not seem to work properly on IE7.
Use the click event with checkboxes. I think you will find that in
some browsers the change event fires only after the input loses focus.
Oct 30 '08 #2

P: n/a
"David Mark" <dm***********@gmail.comwrote in message
news:2a**********************************@f77g2000 hsf.googlegroups.com...
>On Oct 30, 3:17 pm, "Aaron Gray" <ang.use...@gmail.comwrote:
>I am finding that <input type="checkbox"
onchange="alert('test')"></input>
does not seem to work properly on IE7.

Use the click event with checkboxes. I think you will find that in
some browsers the change event fires only after the input loses focus.
Okay great 'onclick' works but how do Iget the checkbox'es value ?

<input type="checkbox" onchange="alert('test' + this.value)"></input>

Is always giving 'on'.

Thanks,

Aaron
Oct 30 '08 #3

P: n/a
On 30 Ott, 20:26, "Aaron Gray" <ang.use...@gmail.comwrote:
"David Mark" <dmark.cins...@gmail.comwrote in message

news:2a**********************************@f77g2000 hsf.googlegroups.com...
On Oct 30, 3:17 pm, "Aaron Gray" <ang.use...@gmail.comwrote:
I am finding that <input type="checkbox"
onchange="alert('test')"></input>
does not seem to work properly on IE7.
Use the click event with checkboxes. *I think you will find that in
some browsers the change event fires only after the input loses focus.

Okay great 'onclick' works but how do Iget the checkbox'es value ?

* * <input type="checkbox" onchange="alert('test' + this.value)"></input>

Is always giving 'on'.

Thanks,

Aaron
simply put a value attribute on it
<input type="checkbox" value ="some_value" onclick="alert('test' +
this.value)"></input>

Bye

Oct 30 '08 #4

P: n/a
On Oct 30, 3:35*pm, xdevel1999 <xdevel1...@gmail.comwrote:
On 30 Ott, 20:26, "Aaron Gray" <ang.use...@gmail.comwrote:
"David Mark" <dmark.cins...@gmail.comwrote in message
news:2a**********************************@f77g2000 hsf.googlegroups.com....
>On Oct 30, 3:17 pm, "Aaron Gray" <ang.use...@gmail.comwrote:
>I am finding that <input type="checkbox"
>onchange="alert('test')"></input>
>does not seem to work properly on IE7.
>Use the click event with checkboxes. *I think you will find that in
>some browsers the change event fires only after the input loses focus.
Okay great 'onclick' works but how do Iget the checkbox'es value ?
* * <input type="checkbox" onchange="alert('test' + this.value)"></input>
Is always giving 'on'.
Thanks,
Aaron

simply put a value attribute on it
What on earth are you talking about?
Oct 30 '08 #5

P: n/a
On Oct 30, 3:26*pm, "Aaron Gray" <ang.use...@gmail.comwrote:
"David Mark" <dmark.cins...@gmail.comwrote in message

news:2a**********************************@f77g2000 hsf.googlegroups.com...
On Oct 30, 3:17 pm, "Aaron Gray" <ang.use...@gmail.comwrote:
I am finding that <input type="checkbox"
onchange="alert('test')"></input>
does not seem to work properly on IE7.
Use the click event with checkboxes. *I think you will find that in
some browsers the change event fires only after the input loses focus.

Okay great 'onclick' works but how do Iget the checkbox'es value ?

* * <input type="checkbox" onchange="alert('test' + this.value)"></input>

Is always giving 'on'.
Perhaps you meant onclick above? Also, the checked property is likely
what you are after. Do you really care about the value?
Oct 30 '08 #6

P: n/a
"David Mark" <dm***********@gmail.comwrote in message
news:dd**********************************@f63g2000 hsf.googlegroups.com...
On Oct 30, 3:26 pm, "Aaron Gray" <ang.use...@gmail.comwrote:
>"David Mark" <dmark.cins...@gmail.comwrote in message

news:2a**********************************@f77g200 0hsf.googlegroups.com...
>On Oct 30, 3:17 pm, "Aaron Gray" <ang.use...@gmail.comwrote:
I am finding that <input type="checkbox"
onchange="alert('test')"></input>
does not seem to work properly on IE7.
>Use the click event with checkboxes. I think you will find that in
some browsers the change event fires only after the input loses focus.

Okay great 'onclick' works but how do Iget the checkbox'es value ?

<input type="checkbox" onchange="alert('test' + this.value)"></input>

Is always giving 'on'.
>Perhaps you meant onclick above?
Yes, sorry :)
>Also, the checked property is likely what you are after.
Ah, got that :)
>Do you really care about the value?
No.

Thanks alot David,

Aaron
Oct 30 '08 #7

P: n/a
On Oct 30, 4:15*pm, "Aaron Gray" <ang.use...@gmail.comwrote:
"David Mark" <dmark.cins...@gmail.comwrote in message

news:dd**********************************@f63g2000 hsf.googlegroups.com...
On Oct 30, 3:26 pm, "Aaron Gray" <ang.use...@gmail.comwrote:
"David Mark" <dmark.cins...@gmail.comwrote in message
>news:2a**********************************@f77g200 0hsf.googlegroups.com....
On Oct 30, 3:17 pm, "Aaron Gray" <ang.use...@gmail.comwrote:
I am finding that <input type="checkbox"
onchange="alert('test')"></input>
does not seem to work properly on IE7.
Use the click event with checkboxes. I think you will find that in
some browsers the change event fires only after the input loses focus..
Okay great 'onclick' works but how do Iget the checkbox'es value ?
<input type="checkbox" onchange="alert('test' + this.value)"></input>
Is always giving 'on'.
Perhaps you meant onclick above?

Yes, sorry :)
Also, the checked property is likely what you are after.

Ah, got that :)
Do you really care about the value?

No.

Thanks alot David,
No problem. One caveat though. It seems to me that there is at least
one old version of Mac IE that will not work as expected. My memory
is fuzzy on this though. I remember consulting on a project a few
years ago that did something like this:

function mycheckboxclick() {
if (isMacIE) {
someglobalflag = this.checked;
} else {
someglobalflag = !this.checked;
}
}

This is madness of course (first thing I did was change the global
flag to a function that returned the present value of the checked
property.) The "reasoning" for the above logic was that a unit test
failed in Mac IE and this hack "fixed" it. This is the same brain-
dead methodology used by Prototype, jQuery, etc. You can probably
imagine my ultimate recommendation (throw the bums out.)
Oct 30 '08 #8

This discussion thread is closed

Replies have been disabled for this discussion.