Monday, 17 July 2017

MVC - jQuery - Get value of selected radio button

Watch this example on YouTube


Html:

USD: @Html.RadioButton("Currency", "USD")
CAD: @Html.RadioButton("Currency", "CAD")
<input type="button" onclick="CheckSelected()" value="click me" />

jQuery

@section Scripts {
    <script type="text/javascript">
        function CheckSelected() {
            var selected = $("input[name='Currency']:checked").val();
            alert(selected);
        }

        $(document).ready(function () {
      
        });
    </script>
}

No comments:

Post a Comment