I've been struggling with this for a good couple of hours now.
I want to add an event listener to all <select>
s on a page and I've got this piece of code so far:
onload = function(e) {
sels = document.getElementsByTagName('select');
for(i=0; i<sels.length; i++) {
sels[i].addEventListener('change', alert('test!'), false);
}
}
This only triggers the alert when the page is loaded and not when I change the value in any of my <select>
s.
Can I get a nudge in the right direction, please? :-)