If the this
value you want is the just the object that you bound the event handler to, then addEventListener()
already does that for you. When you do this:
productLineSelect.addEventListener('change', getSelection, false);
the getSelection
function will already be called with this
set to the object that the event handler was bound to. It will also be passed an argument that represents the event object which has all sorts of object information about the event.
function getSelection(event) {
// this will be set to the object that the event handler was bound to
// event is all the detailed information about the event
}
If the desired this
value is some other value than the object you bound the event handler to, you can just do this:
var self = this;
productLineSelect.addEventListener('change',function() {
getSelection(self)
},false);
By way of explanation:
this
into a local variable in your other event handler.this
.