Image Caption
Showing posts with label radio button value in javascript. Show all posts
Showing posts with label radio button value in javascript. Show all posts

Thursday, February 7, 2013

Get Radio Button Value in JavaScript

Get Radio Button Value in JavaScript
<script>

function getvalue() {
    var radios = document.getElementsByName("test");

    for (var i = 0; i < radios.length; i++) {      
        if (radios[i].checked) {
            alert(radios[i].value);
            break;
        }
    }
}
</script>
<input type="radio" name="test" value="first" onclick="getvalue();">
<input type="radio" name="test" value="second" onclick="getvalue();">