I know that getElementsByTagName and getElementsByClassName need an index identifier in order for the objects to be bound to an event listener.
getElementsByTagName
getElementsByClassName
Try querySelectorAll method.
querySelectorAll
var inputElem = document.querySelectorAll('input');
Which returns a NodeList and you can loop through the array to add the event listeners.
NodeList