well, getElementsByName is a DOM object used to retreive elements with attribute keys name,
like, <input type="image" name="imgButton1" />
However, the attribute id has been replacing the name attribute, and in xhtml standard compliance, the name attribute is almost no where to be found. So technically you should be using getElementsByTagName.
Secondly, if your element doesnt have a name attribute, Im not entirely sure if getElementsByName will even return the object, which is why I asked you to alert the length of that array. Does this make sense? I hope this is the problem, cause thats a lot of code to troubleshoot. =)