lundi 6 février 2017

How to get values of selected checkboxes in jquery?

Hi I am developing jquery application with asp.net. I have list of checkboxes as below. If i check any checkbox then i want to display it. Below is my checkboxlist.

  <asp:CheckBoxList ID="ChKResons" runat="server" RepeatColumns="1" RepeatDirection="Horizontal" Style="margin-bottom: 8px; margin-right: 5px;" CellPadding="5" CellSpacing="25">
                        <asp:ListItem Text="Your financial offer exceeded our budgeted amount" value="1"/>
                        <asp:ListItem Text="Your technical offer didn't comply with Oman Air's technical requirement" Value="2" />
                    </asp:CheckBoxList>

This is my jquery code.

 $('#ChKResons').on('click', ':checkbox', function () {
        if ($(this).is(':checked')) {
            // handle checkbox check
            alert($(this).val());
        } else {
            // checkbox is unchecked
            alert('unchecked')
        }
    });
    $('#ChKResons :checkbox').live('click', function () {
        alert($(this).is(':checked'));
    });

Above code does not work. May i get some help to sort out this? An help would be appreciated. Thank you.




Aucun commentaire:

Enregistrer un commentaire