getElementsByName() not working? [duplicate]
document.getElementsByName()
returns a NodeList, so you have to access it by an index: document.getElementsByName('staff_counter')[0]
(depending on how many of these you have).
You also have access to a length
property to check how many Elements were matched.
Just had a similar issue, I resolved it with a simple loop over the array. The code below will go through and disable all the buttons with the name of 'btnSubmit'.
for (var i=0;i<document.getElementsByName('btnSubmit').length;i++){ document.getElementsByName('btnSubmit')[i].disabled=true;}