I am trying to achieve something here. Once I click a link, the value of a hidden element specified for that link will be set to 1 (0 by default). This works fine.
Next step, I am looping through all hidden elements to see which ones are set to 1. If it is set to 1, I add its ID to a variable. The next one that is set to 1, its ID needs to be put in the same variable behind it.
So the variable with the IDs should look like: hidden1/hidden2/hidden3
It is hard to explain, but here I reconstructed it:
http://jsfiddle.net/UgbMx/
Once I click the the SUBMIT button, it looks up if it is 1 or 0 just fine. Then it loops through the hidden elements. It recongizes that the element is either set to 1 or 0. After that, it goes wrong.
Remove the var statement before test_total inside the callbacks and you will be fine! You are re-declaring the test_total variable within the each-callback scope.
So this part is changed (I truncated the comment for readability):