CheckBoxList Checked All JQuery


function pageLoad(sender, args) {
        $(‘#<%=CheckBoxList1.ClientID %>’ + ‘_0’).click(function () {
            var id = “#<%=CheckBoxList1.ClientID %>_0”;
            var checkboxlistid = “#<%= CheckBoxList1.ClientID %>”;
            if ($(‘#<%=hdIsListCheckAll.ClientId %>’).val() == “True”) {

                if ($(id).attr(‘checked’) == ‘checked’) {
                    var flag = true;
                }
                else {
                    var flag = false;
                }
                $(checkboxlistid + ” input:checkbox”).each(function () {
                    $(this).attr(‘checked’, flag);
                });
            }
        });
    }

 อธิบาย code ‘#<%=CheckBoxList1.ClientID %>’ + ‘_0’
 คือ CheckBox ตัวแรกที่เมื่อเลือกแล้วจะทำการ select ทั้งหมดให้

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: