Changing selectedIndex and onchange events

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

    Changing selectedIndex and onchange events

    Whilst I have no immediate need for it, I've noticed that if a select
    element is changed via setting the selectedIndex value, it does not
    fire an onchange event. Is there any reason for this? Both IE 6 and FF
    2 behave the same in regards to this.

    Is it the developers responsibility to fire this event in such a
    situation?

  • VK

    #2
    Re: Changing selectedIndex and onchange events

    On Mar 20, 7:55 pm, "Tom Cole" <tco...@gmail.c omwrote:
    Whilst I have no immediate need for it, I've noticed that if a select
    element is changed via setting the selectedIndex value, it does not
    fire an onchange event. Is there any reason for this?
    At least for IE there is:
    Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.

    "The onchange event does not fire when the selected option of the
    select object is changed programatically ."

    I don't remember if it is some standard DOM interface feature or a
    "default common behavior" of all browsers. From the practical point of
    view it is not so relevant though.
    Both IE 6 and FF 2 behave the same in regards to this.
    Yes, see above.
    Is it the developers responsibility to fire this event in such a
    situation?
    I'm afraid so. And remember that custom events do not propagate
    (bubble) so you have to fire them for each event consumer separately.

    Comment

    • RobG

      #3
      Re: Changing selectedIndex and onchange events

      On Mar 21, 2:55 am, "Tom Cole" <tco...@gmail.c omwrote:
      Whilst I have no immediate need for it, I've noticed that if a select
      element is changed via setting the selectedIndex value, it does not
      fire an onchange event. Is there any reason for this? Both IE 6 and FF
      2 behave the same in regards to this.
      >
      Is it the developers responsibility to fire this event in such a
      situation?
      The W3C event model provides dispatchEvent, IE provides fireEvent.
      The archives are a remarkable resource - Michael Winter provides a
      very comprehensive answer here:

      subject: How to trigger event programmaticall y?
      <URL:
      http://groups.google.com.au/group/co...cea9cdf065a524
      >

      --
      Rob

      Comment

      Working...