javascript select input event
<p>I'm trying to create a select input from javascript and bind a function to when a user changes an option. So far I have:</p>

<pre><code>    var filter = document.createElement("select");
filter.name = "selectName";
filter.change = function() {
    alert("CHANGED");
}
var pos = 0
for (i in filters){
    var splitted = i.split('.');
    var display = splitted[splitted.length - 2];
    filter.options[pos] = new Option(display, i);
    pos++;
}
</code></pre>

<p>But nothing happens on selecting something else. What is wrong with this code. Also, how can I get the new selected value in the function ? Something like:</p>

<pre><code>   alert(this.value + "has been selected")
</code></pre>
