LyndonOHRC
Programmer
I'm trying to set an event handler and avoid using the event parameter in my input tags. I'll be addressing the cross-browser issue with this function but I hit a wall implementing the IE code.
I have this strategy in use for another event where the function does not need a parameter and it works great, such as: oInputs.attachEvent('onkeyup',formhasChanged);
However when I need to pass a value to my event function I get an "object required" error when the function calls the input/textarea object on the line "var y=document.getElementById(elem).value;". The object reference elem is apparently not an object.
Any ideas on how to accomplish this?
Thanks
Lyndon
---People Remember about 10% of what you say ---They never forget how you made them feel. Covey
I have this strategy in use for another event where the function does not need a parameter and it works great, such as: oInputs.attachEvent('onkeyup',formhasChanged);
However when I need to pass a value to my event function I get an "object required" error when the function calls the input/textarea object on the line "var y=document.getElementById(elem).value;". The object reference elem is apparently not an object.
Any ideas on how to accomplish this?
Thanks
Code:
<body onload="setonkeyupEvent();">
function setonkeyupEvent(){
var oInputs = document.getElementsByTagName('textarea');
for (var i = 0; i < oInputs.length; i++){ oInputs[i].attachEvent('onkeyup',function(){upperCase(this.id)})
}
}
function upperCase(elem){
var y=document.getElementById(elem).value;
document.getElementById(elem).value=y.toUpperCase();
}
Lyndon
---People Remember about 10% of what you say ---They never forget how you made them feel. Covey