Pure Javascript – Get value of selected radio button

Here is a small function to get the value of a selected radio button without using jQuery:

function getRadioValue(name) {
    var radios = document.getElementsByName(name);

    for (var i = 0; i< radios.length; i++) {        
        if (radios[i].checked) 
            return radios[i].value;

If you do not care about compatibility with Explorer versions below 9:


Leave a Comment

Your email address will not be published. Required fields are marked *