Prior to the introduction of the Selectors API, the only way to get the value of a radio button group was to iterate over the members:
function getRadioValue(group) {
for (var i=0, iLen=group.length; i<iLen; i++) {
if (group[i].checked) {
return group[i].value;
}
}
// No button selected - return '' or undefined?
return '';
}
console.log(getRadioValue(document.forms['radio-mc']['mc'])); // value
However, as cookie monster commented, you can use querySelectorAll for browsers that support it:
var checked = document.forms['radio-mc'].querySelector('input:checked');
console.log(checked? checked.value : '');
If you have more than one set of radio buttons in the form, or also have checkboxes, you'll need something like:
document.forms['radio-mc'].querySelector('[name=mc]:checked')
otherwise you'll just get the first checked radio or checkbox.
Also, since you don't have a default selected button, you need to handle the case where no button is selected.