Reputation: 7361
I made an extract of my code to help explain this: http://jsfiddle.net/DF2Uw/1/
I basically want to see when a user changes the value of slottime. I use a simple onchange handler: slottime.setAttribute(onchange, alert("oh no"));
However this seems to trigger as soon as the select gets generated on the page instead of when the value is changed. I don't understand why, this makes no sense to me.
Can anybody explain the logic to me and maybe propose a fix?
Upvotes: 0
Views: 50
Reputation: 8715
.addEventListener
instead of setting attribute.alert()
. Change it to: setAttribute('onchange', 'alert("oh no")')
Fiddle with .addEventListener
: http://jsfiddle.net/DF2Uw/2/
Upvotes: 1