1

Can someone explain to me when the onchange event is triggered in JS. Because I am making multiple drop-down lists where each one depends on the previous one's answer. But all the onchange events are firing, even though the selectItemIndex isn't changing...

Matt
  • 4,462
  • 5
  • 25
  • 35
Leonardo Coelho
  • 175
  • 2
  • 10

2 Answers2

2

It occurs when the actual .value changes, which doesn't officially occur until it loses focus. Can be the same as onblur event. Check this page posted from this question for more information on events.

Community
  • 1
  • 1
tbm0115
  • 410
  • 11
  • 21
0

I found this

The onchange event occurs when the value of an element has been changed.

For radiobuttons and checkboxes, the onchange event occurs when the checked state has been changed.

Tip: This event is similar to the oninput event. The difference is that the oninput event occurs immediately after the value of an element has changed, while onchange occurs when the element loses focus. The other difference is that the onchange event also works on keygen and select elements.

you can see more here http://www.w3schools.com/jsref/event_onchange.asp

If you change the content of the dropdown you are also firing the onchange event.

Marco Mendão
  • 329
  • 2
  • 5