input checkbox onchange not working on IE7

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

    input checkbox onchange not working on IE7

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



    It works fine on FF and Google Chrome.

    Any suggestions ?

    Many thanks in advance,

    Aaron


  • David Mark

    #2
    Re: input checkbox onchange not working on IE7

    On Oct 30, 3:17 pm, "Aaron Gray" <ang.use...@gma il.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.

    Comment

    • Aaron Gray

      #3
      Re: input checkbox onchange not working on IE7

      "David Mark" <dmark.cinsoft@ gmail.comwrote in message
      news:2a2d567a-f2c2-4b33-aa84-089183e2f8db@f7 7g2000hsf.googl egroups.com...
      >On Oct 30, 3:17 pm, "Aaron Gray" <ang.use...@gma il.comwrote:
      >I am finding that <input type="checkbox"
      >onchange="aler t('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


      Comment

      • xdevel1999

        #4
        Re: input checkbox onchange not working on IE7

        On 30 Ott, 20:26, "Aaron Gray" <ang.use...@gma il.comwrote:
        "David Mark" <dmark.cins...@ gmail.comwrote in message
        >
        news:2a2d567a-f2c2-4b33-aa84-089183e2f8db@f7 7g2000hsf.googl egroups.com...
        >
        On Oct 30, 3:17 pm, "Aaron Gray" <ang.use...@gma il.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

        Comment

        • David Mark

          #5
          Re: input checkbox onchange not working on IE7

          On Oct 30, 3:35 pm, xdevel1999 <xdevel1...@gma il.comwrote:
          On 30 Ott, 20:26, "Aaron Gray" <ang.use...@gma il.comwrote:
          >
          >
          >
          "David Mark" <dmark.cins...@ gmail.comwrote in message
          >
          news:2a2d567a-f2c2-4b33-aa84-089183e2f8db@f7 7g2000hsf.googl egroups.com....
          >
          >On Oct 30, 3:17 pm, "Aaron Gray" <ang.use...@gma il.comwrote:
          >I am finding that <input type="checkbox"
          >onchange="aler t('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?

          Comment

          • David Mark

            #6
            Re: input checkbox onchange not working on IE7

            On Oct 30, 3:26 pm, "Aaron Gray" <ang.use...@gma il.comwrote:
            "David Mark" <dmark.cins...@ gmail.comwrote in message
            >
            news:2a2d567a-f2c2-4b33-aa84-089183e2f8db@f7 7g2000hsf.googl egroups.com...
            >
            On Oct 30, 3:17 pm, "Aaron Gray" <ang.use...@gma il.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?

            Comment

            • Aaron Gray

              #7
              Re: input checkbox onchange not working on IE7

              "David Mark" <dmark.cinsoft@ gmail.comwrote in message
              news:ddfd4e46-7d08-4913-848c-091f56fa7491@f6 3g2000hsf.googl egroups.com...
              On Oct 30, 3:26 pm, "Aaron Gray" <ang.use...@gma il.comwrote:
              >"David Mark" <dmark.cins...@ gmail.comwrote in message
              >>
              >news:2a2d567 a-f2c2-4b33-aa84-089183e2f8db@f7 7g2000hsf.googl egroups.com...
              >>
              >On Oct 30, 3:17 pm, "Aaron Gray" <ang.use...@gma il.comwrote:
              >I am finding that <input type="checkbox"
              >onchange="aler t('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


              Comment

              • David Mark

                #8
                Re: input checkbox onchange not working on IE7

                On Oct 30, 4:15 pm, "Aaron Gray" <ang.use...@gma il.comwrote:
                "David Mark" <dmark.cins...@ gmail.comwrote in message
                >
                news:ddfd4e46-7d08-4913-848c-091f56fa7491@f6 3g2000hsf.googl egroups.com...
                On Oct 30, 3:26 pm, "Aaron Gray" <ang.use...@gma il.comwrote:
                >
                >
                >
                "David Mark" <dmark.cins...@ gmail.comwrote in message
                >
                >news:2a2d567 a-f2c2-4b33-aa84-089183e2f8db@f7 7g2000hsf.googl egroups.com....
                >
                On Oct 30, 3:17 pm, "Aaron Gray" <ang.use...@gma il.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.)

                Comment

                Working...