Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

onChange/addEventListenres

Can someone please help me with this challenge:

http://teamtreehouse.com/library/adding-multiple-event-listeners

3 Answers

The problem with using onchange, is that if you try to register multiple function with the event, you end up overwriting the previous references, and end with only the last function linked to the event. This challenge wants you to use addEventListener instead. This way, you can register multiple functions with the 'change' event. Try this:

navigationSelect.addEventListener('change', navigateToValue);
navigationSelect.addEventListener('change', sendAnalytics);

Ah, now it makes sense. Sometimes i get more out of the forums than i do out of the lessons!

I know how you feel. The advantage the forums have is that you can ask a direct question about exactly what isn't making sense. The videos have to be very broad in what they cover. Glad I could help!

So why does navigationSelect.addEventListener('change', navigateToValue) = navigateToValue; navigationSelect.addEventListener('change', sendAnalytics) = sendAnalytics;

need the additional argument in the challenge? And thanks for the forum...Chalkley is a bit hard to follow at times.