adding event handling to HTML objects

How would I add an event listener (onchange, onclick) to an HTML object after it has been created? For example: a basic text input is created and when a button is pushed later, the text input gains the property:onkeyup="this.value=this.value.toUpperCase()"
[284 byte] By [vinays84a] at [2007-11-26 16:21:42]
# 1

"onkeyup" is a property you can set to a function. Something like this:

function test()

{

alert("test!");

}

document.getElementById("yourtextfield").onkeyup = test;

That should do it, if you give your textfield the id "yourtextfield".

This page listst the event handler attributes you can set:

http://www.w3.org/TR/html4/interact/scripts.html

gimbal2a at 2007-7-8 22:45:25 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Thanks!
vinays84a at 2007-7-8 22:45:25 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...