The event listeners I am adding do not seem to function when the event occurs. Using the inline javaScript method the events work fine (see below).
I want to add the event listeners as suggested by Dormilich. Which with the help of Dormilich, I was able to do on a form I create on the fly. See http://bytes.com/topic/javascript/an...ll#post3657732.
Now I am trying to add more to other controls on my form. Here is my code.
Here is the basic form with same control example as above. I want to hook the two event listeners (see code above) to the "ID" input box. The onload event handler for the body works fine and fires after the page has loaded.
Here is how I create the event listeners in my .js library
References to the other functions in the eventListeners are the same in both the inline javaScript and eventListener so I know they function fine.
So why does the event not fire when they happen?
Code:
<input type = "text" id = "ID" onKeyPress="this.value = this.value.toUpperCase(); return isId(event, this);" onChange="requestClient(); DataChanged()" />
Now I am trying to add more to other controls on my form. Here is my code.
Here is the basic form with same control example as above. I want to hook the two event listeners (see code above) to the "ID" input box. The onload event handler for the body works fine and fires after the page has loaded.
Code:
<head>
<script language="JavaScript">
<!--
function myStartUp(obj){
assignEventListeners();
}
//-->
</script>
</head>
<body onLoad = "myStartUp(this);">
... other code ...
<input type = "text" id = "ID" />
... other code ...
</body>
Code:
//global object
var g = {};
function assignEventListeners(){
g.getClient = document.getElementById('ID');
if (g.getClient.addEventListener)
{
g.getClient.addEventListener("onChange",function(){requestClient();},false);
}
g.setToUpper = document.getElementById('ID');
if (g.setToUpper.addEventListener)
{
g.setToUpper.addEventListener("onKeyPress",
function()
{
this.value = this.value.toUpperCase();
return isId(event, this);
},
false)
}
return;
}
So why does the event not fire when they happen?
Comment