Wednesday, September 28, 2011

Check Uncheck radio button with java script

  <script language="javascript" type="text/javascript">
   function CheckUncheckRadio(id) {
            var val;
            var rdo = document.getElementById(id)
            var radio = rdo.getElementsByTagName("input");
            if (radio.checked == true) {

                radio.checked = false;
                val = 0;
            }
            else {

                radio.checked = true;
                val = 1;
            }

            if (val == 0) {
                rdo.checked = false;
            }
            else {
                rdo.checked = true;
            }
        }

    </script>





 <asp:RadioButton ID="rbExpenseCost" runat="server" Text="1" onclick="CheckUncheckRadio('rbExpenseCost');"/>

<asp:RadioButton ID="rbLeaveCost" runat="server"  Text="2" onclick="CheckUncheckRadio('rbLeaveCost');" />
                                                 












No comments:

Post a Comment