Friday 22 June 2012

Check Radio button from JavaScipt


Find which Radio button is Checked from JavaScript : 

JS :
 function check(obj) {
           var a = null;
           var f = document.forms[0];
           var e = f.elements[obj];
if (e[0].checked == true) {               
alert(“1 radio button is checked”)
}
           else {
alert(“2 radio button is checked”)
           }
       }


 HTML :
  <asp:RadioButtonList ID="RDB" runat="server" >
           <asp:ListItem Value="1">Ajay</asp:ListItem>
           <asp:ListItem Value="2">Patel</asp:ListItem>
        </asp:RadioButtonList>
        <asp:Button ID="btn" runat="server" Text="Button" />
        <input type="submit" value="submit" />

No comments:

Post a Comment