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 trialYohan Aton
1,738 PointsDrawing a blank on the solution...
Hi, thanks for taking a sec. If you can post the solution, I believe I can see it and understand it.
Thank You!!!
//Select select box
var navigationSelect = document.getElementById("nav");
//Navigate to URL when select box is changed
var navigateToValue = function() {
window.location = this.value;
}
//Send analytics data
var sendAnalytics = function() {
//Placeholder
}
navigationSelect.change.addEventListener() = navigateToValue;
navigationSelect.change.addEventListener() = sendAnalytics;
2 Answers
Steven Parker
231,275 PointsSPOILER ALERT
You had the right idea to create additional event "listeners", each of which will invoke a function when the event occurs. But instead of using assignments the call takes two arguments, first the type of event to respond to, and the next is the function to invoke.
So change the last two lines to:
navigationSelect.addEventListener("change", navigateToValue);
navigationSelect.addEventListener("change", sendAnalytics);
Mark Miller
45,831 PointsHow did you know of the event called "change" for the select menu with the id "nav"? I understand that "change" represents the event when a visitor selects an option from the select menu, but the only place where I see the word "change" representing this event is here in the Treehouse community forum. I am unable to find the word "change" representing an event, for the selection of an option from a menu, anywhere in the Mozilla Developer Network documentation for the addEventListener. Now I could pass this quiz, but I did not know why it was "change" representing the event. So, in the future, I am not able to find the names of the events that could trigger the listeners.
Yohan Aton
1,738 PointsThank You!!!!
Steven Parker
231,275 PointsSteven Parker
231,275 PointsRemember to select "best answer". :)