inserting javascript into an element

Can someone tell me if it's possible to
insert javascript code as an element's
attribute's value?

That is, I create a select element; I also create 
some option elements, appending each one as a child 
to the select element as I create them.

To the select element, I add an attribute 
called "onchange", and it's value is:
"alert('option changed')"; that is, I do:

var e = document.createElement("select");
e.setAttribute("onchange", "alert('option changed')");


I bring up the page on my browser, I do see
the pulldown, but when I change the option,
I don't get the javascript alert like I expect
to.

Am I doing this correctly? If not how can I 
do this?

Thanks!
-alex

__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

Received on Thursday, 6 December 2001 12:54:38 UTC