If you do not show the corresponding HTML there is no way we can help you. As it stands the code is meaningless.
Have you tried using your error console (F12)?
Have you tried placing alerts at strategic positions to inspect the values at that stage?
What is the point of using an object var v = new Object(); here?
We are in unprecedented territory, and we have been here before. Presenter, BBC Radio 2
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.