I don't see anything in the supplied code that would affect your <div id='counter'>
It won't change unless you make it change. Unfortunately, since it's a <div> element it does not have a value= property.
What you need to do to modify the content is to change the content of the element like so:
document.getElementByID('counter').innerHTML = (the new value)
. You can actually set it to pretty much anything with any sort of value and not just numeric values.
See also:
HTML DOM innerHTML Property[
^]