Hi,
I use code like this to dynamically create some link-based controls:
<script type="text/javascript">
function BuildControls (id, ...)
{
var div = document.getElementById (id);
/* some stuff with var sp=document.createElement('span'); */
var a = document.createElement ('a');
a.innerHTML = on ? 'Cancel' : captions_do[i];
a.className = class_do;
a.style.display = on2 ? '' : 'none';
a.id = 'iAccept'+id+'_'+i+'Control';
div.appendChild (sp);
div.innerHTML+='<br />';
div.appendChild (a);
a.onclick = function () {alert ('wtf')};
div.innerHTML+='<br />';
}
</script>
...
<div id="someid"></div>
<script type="text/javascript">
BuildControls ('someid', ...);
</script>
So when I click on the link, it does nothing. If I call a.onclick() explicitly, it works. What is wrong?