The getElementsByTagName is plural as it returns a (possibly empty) NodeList of elements that match the given name.
To get the selected button, loop over the NodeList (I've turned it into a function):
function getCheckedButton(name) {
var buttons = document.getElementsByName(name);
for (var i=0; i<buttons.length; i++) {
if (buttons[i].checked) {
return buttons[i];
}
}
If you just want the button's value:
return buttons[i].value
You could also use querySelector:
function getCheckedValue(name) {
var button = document.querySelector('input[name=' + name + ']:checked');
return button && button.value;
}
However, querySelector isn't supported by all browsers in use and complex selectors aren't supported by all those that support querySelector.