javascript - Get asp.net RadioButtonList selected value with jQuery -
i want uncheck radiobuttonlist
if click on listitem
yet checked. code of radio:
<div class="filtrodiv100" style="margin-top: 17px;"> <asp:radiobuttonlist id="rbttipi" runat="server" onclick="resetfun();" style="margin-top: 4px; margin-bottom: 8px;"> <asp:listitem value="industriale"> addizionale regionale industriale</asp:listitem> <asp:listitem value="civile"> addizionale regionale civile</asp:listitem> <asp:listitem value="sostitutiva"> addizionale regionale sostitutiva</asp:listitem> <asp:listitem value="imposta"> imposta gas</asp:listitem> </asp:radiobuttonlist> </div>
my function:
<script type="text/javascript" > function resetfun() { var radiobuttons = $('#<%=rbttipi.clientid%>'); var id= $(this).attr('value') } } </script>
firstly, onclick
attribute should onchange
. because onchange
captures change onclick fires after clicked , before change happens.
write resetfun()
function below.
function resetfun() { var radiobuttons = $('#<%=rbttipi.clientid%>'); var id = radiobuttons.find('input:checked').val(); // selected value }
alternative solution:
write onchange attribute onchange="resetfun(this);"
. pass radio button list element parameter javascript function.
and resetfun
function below:
function resetfun(radio) { alert($(radio).find('input:checked').val()); }
Comments
Post a Comment