attach function with parameter from javascript
<p>I have this function:</p>

<pre><code>function addButtonLookup() {

    var element = document.getElementById("btnToolBar");
    var index;
    for (var i = 0; i &lt; lookupArray.length; i++) {

        index = i;

        var btn = document.createElement('input');
        btn.type = 'button';
        btn.value = '' + lookupArray[i];
        btn.name = 'btnLookup' + i;
        btn.id = i;
        btn.className = 'CommonButtonStyle';
        element.appendChild(btn);
        btn.onclick = function() {
            debugger;

            tblExcpression.WriteMathElement(lookupArray[i], lookupArray[i]);
        };


    }

}
</code></pre>

<p>onbutton click the i is undefined</p>
