I can suggest a few items that may have gone wrong:
You can use alert() and console.log to check the values of those.