Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > input checkbox onchange not working on IE7

Reply
Thread Tools

input checkbox onchange not working on IE7

 
 
Aaron Gray
Guest
Posts: n/a
 
      10-30-2008
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


 
Reply With Quote
 
 
 
 
David Mark
Guest
Posts: n/a
 
      10-30-2008
On Oct 30, 3:17*pm, "Aaron Gray" <ang.use...@gmail.com> wrote:
> 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.
 
Reply With Quote
 
 
 
 
Aaron Gray
Guest
Posts: n/a
 
      10-30-2008
"David Mark" <> wrote in message
news:2a2d567a-f2c2-4b33-aa84-...
>On Oct 30, 3:17 pm, "Aaron Gray" <ang.use...@gmail.com> wrote:
>> 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


 
Reply With Quote
 
xdevel1999
Guest
Posts: n/a
 
      10-30-2008
On 30 Ott, 20:26, "Aaron Gray" <ang.use...@gmail.com> wrote:
> "David Mark" <dmark.cins...@gmail.com> wrote in message
>
> news:2a2d567a-f2c2-4b33-aa84-...
>
> >On Oct 30, 3:17 pm, "Aaron Gray" <ang.use...@gmail.com> wrote:
> >> 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

 
Reply With Quote
 
David Mark
Guest
Posts: n/a
 
      10-30-2008
On Oct 30, 3:35*pm, xdevel1999 <xdevel1...@gmail.com> wrote:
> On 30 Ott, 20:26, "Aaron Gray" <ang.use...@gmail.com> wrote:
>
>
>
> > "David Mark" <dmark.cins...@gmail.com> wrote in message

>
> >news:2a2d567a-f2c2-4b33-aa84-....

>
> > >On Oct 30, 3:17 pm, "Aaron Gray" <ang.use...@gmail.com> wrote:
> > >> 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?
 
Reply With Quote
 
David Mark
Guest
Posts: n/a
 
      10-30-2008
On Oct 30, 3:26*pm, "Aaron Gray" <ang.use...@gmail.com> wrote:
> "David Mark" <dmark.cins...@gmail.com> wrote in message
>
> news:2a2d567a-f2c2-4b33-aa84-...
>
> >On Oct 30, 3:17 pm, "Aaron Gray" <ang.use...@gmail.com> wrote:
> >> 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?
 
Reply With Quote
 
Aaron Gray
Guest
Posts: n/a
 
      10-30-2008
"David Mark" <> wrote in message
news:ddfd4e46-7d08-4913-848c-...
On Oct 30, 3:26 pm, "Aaron Gray" <ang.use...@gmail.com> wrote:
>> "David Mark" <dmark.cins...@gmail.com> wrote in message
>>
>> news:2a2d567a-f2c2-4b33-aa84-...
>>
>> >On Oct 30, 3:17 pm, "Aaron Gray" <ang.use...@gmail.com> wrote:
>> >> 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


 
Reply With Quote
 
David Mark
Guest
Posts: n/a
 
      10-30-2008
On Oct 30, 4:15*pm, "Aaron Gray" <ang.use...@gmail.com> wrote:
> "David Mark" <dmark.cins...@gmail.com> wrote in message
>
> news:ddfd4e46-7d08-4913-848c-...
> On Oct 30, 3:26 pm, "Aaron Gray" <ang.use...@gmail.com> wrote:
>
>
>
> >> "David Mark" <dmark.cins...@gmail.com> wrote in message

>
> >>news:2a2d567a-f2c2-4b33-aa84-....

>
> >> >On Oct 30, 3:17 pm, "Aaron Gray" <ang.use...@gmail.com> wrote:
> >> >> 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.)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
input checkbox onclick not working via DOM on IE7, FF, WebKit Aaron Gray Javascript 4 10-31-2008 03:45 PM
text input onChange not firing ms Javascript 4 01-25-2005 01:12 AM
CheckBox onChange Event news.microsoft.com ASP .Net Web Controls 1 12-03-2004 05:10 PM
input type="file" onchange not firing Ron Brennan Javascript 1 05-09-2004 06:36 PM
onChange with checkbox Wim Roffal Javascript 4 11-06-2003 10:25 AM



Advertisments