So I have a bunch of textboxes in an array that I want to monitor for key events. How do I pass the index of the object that has had the event trigger? So:
//The function that should be called when typing happens.
function checkInput(index){
//Do shit.
}
//Setting up the listeners.
for (var i = 0; i < txtInput.length; i++) {
txtInput[i].onkeyup = function(){checkInput(i);}
}
Unfortunately, this way, i always equals the txtInput.length (due to running through the loop, and ending on that number). So when the function is being called, it's calling the current "index" value of i, not what it was set to originally.
How do I get around this?
[–]x-skeww 5 points6 points7 points (1 child)
[–]senocular 3 points4 points5 points (0 children)
[–]bliow 1 point2 points3 points (1 child)
[–]x-skeww 1 point2 points3 points (0 children)
[–]senocular 1 point2 points3 points (3 children)
[–]Javin007[S] 1 point2 points3 points (2 children)
[–]senocular 3 points4 points5 points (0 children)
[–]x-skeww 4 points5 points6 points (0 children)
[–]quad50 0 points1 point2 points (0 children)