i am working on a GreaseMonkey userscript this is the rough structure of my code, with some hard-coded example values:
when i now click on the element "someOtherFunction" gets called with an "i" = 1
"someOtherFunction" should be called with "i" = 0
//edit: i reduced the problem to this: http://pastebin.com/2NXCWBY8
Hmm that doesn't quite make sense. I've just tested with:
And I get a message box displaying 0, then 1 which is the expected result. Can you show the entire code?
i appears to be a global and you're also creating a closure around it when you define your anonymous function for the click handler.
It's impossible to tell what changes you need to make to get the desired behavior without the actual code.