add onSelect event

passing selected element to the event function