samedi 15 juillet 2017

How to get value of checkbox onchange without id or class using JQUERY?

I wants to alert checkbox value if selected.And it will not have any id or class. It's a listbox item which is having checkbox. User may select multiple checkbox.

Here is my ASPX code

<asp:ListBox ID="ListStoreID" CssClass="multiselect" runat="server" SelectionMode="Multiple" DataSourceID="SqlDataSource3" DataTextField="ID" DataValueField="ID">

</asp:ListBox>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:HQMatajer13 %>" SelectCommand="SELECT [ID] FROM [Store] WHERE ([Inactive] = @Inactive)">
     <SelectParameters>
          <asp:Parameter DefaultValue="false" Name="Inactive" Type="Boolean" />
     </SelectParameters>
</asp:SqlDataSource>

<script type="text/javascript">
    $(function () {
        $('[id*=ContentPlaceHolder1_ListStoreID]').multiselect({
            includeSelectAllOption: false,
            buttonText: function (options, select) {
                return 'StoreID';
            },
            buttonTitle: function (options, select) {
                var labels = [];
                options.each(function () {
                    labels.push($(this).text());
                });
                return labels.join(' - ');
            }
        });
    });
    </script>

I am using SQLDataSource to bring the list from database. So It will not have any id or class.

screanshot

screenshot of aspx code




Aucun commentaire:

Enregistrer un commentaire