DHTML: Add event dispatcher to HTML form field
Sure you can use this function with any DOM object. Not only a form field.
/* event dispatcher */
function installAC(frm, fld) {
a = document.forms[frm].elements[fld];
if (a.addEventListener) {a.addEventListener("keyup", PerformActions, false)} // firefox
else if (a.attachEvent) {a.attachEvent("onpropertychange", PerformActions)} // ie
}
/* actions to do */
function PerformActions(h) {
// your code here
}
Comments
Post a Comment