i don't know if i understood well the problem, anyway i give some hint that could be usefull
you'r using a getElementById ?
that should be why you get only one element.
i suggest you using jquery to get the collection of items that you need to manipulate.
a lot of stuff can be founded here
http://jquery.com/[
^]
ex :
<a id="test" class="classTest">text</a>
you can get the element by $('#test'), or every element with the same class as $('.classTest')
in the second case then you can loop foreach element and do what you need