HTML Code:
<script type="text/javascript">
document.write('<span id="test">Test</span>');
t=document.getElementById('test');
t.setAttribute('onclick',bork); /* Set onclick attribute */
function bork(e)
{
alert('Bork');
}
</script>
Hmmmm, I tried the code above a couple of ways but couldn't get it to work. I think it may be due to the fact that I'm dynamically building the list via javascript, but I really don't know yet.
On the dupe-prevention, I did resort to just searching the list each time and rejecting the element addition if it was already there.
Finally (or maybe not, lol) I swear that IE is the most retarded browser in the Universe. Now, maybe there's
another Universe where IE is not the most retarded browser, but that remains to be seen. I say this for one simple reason:
IE just doesn't support event handlers from the option element. In other words, this code here won't work:
HTML Code:
<form>
<select>
<option onclick="doSomething()">Option Number 1</option.
</select>
</form>
It'll work in every browser that I know of
except IE. The onclick only works in IE when it's used on the <select> tag. Yeah, there are workarounds to handle both cases, but I'm so sick of having to code extra junk for IE that I want to vomit. IE simply does not follow the HTML specifications:
Forms in HTML documents
http://www.w3.org/TR/html401/interact/forms.html#h-17.6
It says right there that the <OPTION> part of the <SELECT> element has an onclick event handler available. Not "
maybe", not "
optionally", not "
if Microsoft feels like it", the spec says it will contain this event as an
intrinsic property.