I'm having trouble getting the value of i to be passed on to the scMotion function
for ( i = 0; i < tmp.length; i++ ) {
document.getElementById("sc"+i).onmousedown=function() { return scMotion(i,'up') };
}
To clarify the question, this for loop is doing other stuff, adding elements to the dom.
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.
iis in different scope. That's the problem.varAt the beginning of declaring the variable makes it accessible. The different scope shouldn't matter.