So I have a control (textbox) being created for each row in my grid view. (c#.net)
So for each of the text boxes, I want to find the current active element and return its id.
it kind of works, but I am having some issues.
I know item.addEventListener does not return a value.
Any ideas on how i can return the value after calling the addListener() function?
var controls = {
txt: null,
};
var selectedTextArea;
var items = document.getElementsByClassName("textboxnew");
for (var i = 0; i < items.length; i++) {
controls = addListener(items[i], controls);
alert(controls.txt); ///GET ERROR HERE
}
function addListener(item, ctrls) {
selectedTextArea = document.activeElement;
ctrls.txt = selectedTextArea.name.toString();
item.addEventListener("click", function () {
selectedTextArea = document.activeElement;
ctrls.txt = selectedTextArea.name.toString();
alert(ctrls);
});
return ctrls; //VALUE NOT RETURNED ???
}