Javascript pass variable to event function
<p>I'm having trouble getting the value of i to be passed on to the scMotion function </p>

<pre><code>for ( i = 0; i &lt; tmp.length; i++ ) {
document.getElementById("sc"+i).onmousedown=function() { return scMotion(i,'up') };
}
</code></pre>

<p>To clarify the question, this for loop is doing other stuff, adding elements to the dom.</p>

<p>For some reason even if i is at number 39 the value of i being passed in the function I ma attaching is the final value of i i.e 80.</p>
