Possible Duplicate:
How do I pass the value (not the reference) of a JS variable to a function?
i have several links (var a[]) with an onclick event on them. this works well so far by using one function:
function setCurrentImage(x) {
    return function() {
        alert("Image: "+x);
        return false;
    }
}
for(var i = 0; i < a.length; i++) {
    a[i].onclick = setCurrentImage(i);
}
the thing is, i need two functions. and this code just won't work:
function setCurrentImage(x) {
    return function() {
        alert("Image: "+x);
    }
}
function setCurrentNote(x) {
    return function() {
        alert("Note: "+x);
    }
}
for(var i = 0; i < a.length; i++) {
    a[i].onclick = function() {
        setCurrentImage(i);
        setCurrentNote(i);
        return false;
    }
}
what is wrong with this code? thanks in advance :)
 
     
     
    