Friday, February 1, 2013

Handlin radio button with value javascript

<script type="text/javascript">
    function Str() {
        var theSelectedRadio = document.getElementsByName("x");       
        for (var i = 0; i < theSelectedRadio.length; i++) {           
            if (theSelectedRadio[i].checked) {
                alert(theSelectedRadio[i].value);
            }
        }       
    }
    </script>

<body>
</body>


<input id="x" type="radio" name="x" value="true" />
    <input id="y" type="radio" name="x" value="false" />
    <input id="z" type="radio" name="x" value="NotSelected" />
    <input type="radio" name="x" value="NotSelectedThere" />
    <input type="button" value="s" onclick="Str()" />

No comments:

Post a Comment