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

Using Trello and Confluence to manage UX design project. Part 2

Using Trello and Confluence to manage UX design project. Part 1

Conceptual design