I have a simple web form that uses JavaScript for building a POST statement. In Chrome, I can use a simple line of code...
var form = document.forms[\'myForm\'];
Short & clear on ES-2015, for use with Babel:
function getValueFromRadioButton( name ){ return [...document.getElementsByName(name)] .reduce( (rez, btn) => (btn.checked ? btn.value : rez), null) } console.log( getValueFromRadioButton('payment') );