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

Popular posts from this blog

Axure RP: Image over button - Where do I put the interaction?

Data visualization for Roadmap Microsite (Angular and D3.js)