Hey everyone,

I am looping through all the inputs on a page, then trying to get the name attribute of the element that's clicked.

Code:
var allInputs = document.getElementsByTagName('input');
        for (var i = 0; i < allInputs.length; i++) {
            if (allInputs[i].className == 'someclass') {
                allInputs[i].onmousedown = function () {
                    alert(allInputs[i].name);
                }
            }
        }
When I click on any of the inputs I get a "Uncaught TypeError: Cannot read property 'name' of undefined". What am I doing wrong?

Thanks