找不到JavaScript错误

I would like to add new attribute to select box which name and id are 'firm_id'. So far I have tried with this code, its working fine in mozila but not working in IE.

I am doing this with javascript because select box is coming from ajax. The function sbmtfrm() is not calling in IE.

Error: Message: 'FB' is undefined.

May be FB is a object called in my js lib files, but now i am writing code within a another saperate script tag.

<script type="text/javascript">

    function sbmtfrm()
    {
       alert('now submitting...');
       document.frmsearch.submit();
    }

    function setOnclickAtt(name)
    {
        alert("'"+name+"'" + document.getElementById(name).getAttribute('onchange'));
        alert(document.getElementById(name));
        if(document.getElementById(name))
        {
            alert('attrr changed');
            var ref = document.getElementById(name);
            ref.setAttribute('onchange', 'sbmtfrm();');
            alert("now new atrr = " + document.getElementById(name).getAttribute('onchange'));
        }
        else
        {
            alert('again');
            setTimeout("setOnclickAtt('firm_id')",100);
        }
    }

    setOnclickAtt('firm_id');

</script>   

Any suggestion or ideas would be greatly appreciated.

Thanks a lot.

I think IE is picky when it comes to event handling. Try:

ref.onchange = sbmtfrm;

instead of:

ref.setAttribute('onchange', 'sbmtfrm();');

Also, I think the error message has nothing to do with this issue. It´s wrong but it´s another issue.