--scenario
header checkbox is there..
1)if i check the header check box ,,,all the child checkbox will be checked
2)if uncheck all will be unchecked
3)if everything is checked..if i uncheck one child checkbox...header checkbox will be unchecked
4)if i check one by one all the child checkbox....header checkbox will be checked.
1,2 and 3 are working fine. 4th is not working
chkb1 is header checkbox
chkb2 is child checkbox
<script type="text/javascript">
$(function(){
$('[id*=chkb1]').click(function(){
$("[id*='chkb2']").attr("checked",this.checked);
});
$('[id*=chkb2]').click(function(){
if($('[id*=chkb2]').length== $("[id*='chkb2']: checked").length)
{
$("[id*='chkb1']").attr("checked",this.checked);
}
else
{
$("[id*='chkb1']").removeAttr("checked");
}
});
});</script>
----gridview having checkbox
<asp:GridView ID="GridZeroApprovedKm" AllowPaging="true" runat="server" AutoGenerateColumns="false"
DataKeyNames="Address_id" OnRowCancelingEdit="GridZeroApprovedKm_RowCancelingEdit"
OnRowDataBound="GridZeroApprovedKm_RowDataBound" OnRowDeleting="GridZeroApprovedKm_RowDeleting"
OnRowEditing="GridZeroApprovedKm_RowEditing"
OnRowUpdating="GridZeroApprovedKm_RowUpdating"
onpageindexchanging="GridZeroApprovedKm_PageIndexChanging">
<SelectedRowStyle CssClass="ResultSelectedRow" BackColor="Cyan" />
<Columns>
<asp:TemplateField HeaderText="Select All">
<HeaderTemplate>
<asp:CheckBox ID="chkb1" runat="server" Text="Select All" OnCheckedChanged="sellectAll"
AutoPostBack="true" />
</HeaderTemplate>
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<ItemTemplate>
<asp:CheckBox ID="chkb2" runat="server" OnCheckedChanged="sellectAllChildcheckbox" Text="Select" AutoPostBack="true" />
</ItemTemplate>
<ItemStyle HorizontalAlign="center" />
</asp:TemplateField>
---is this syntax incorrect
if($('[id*=chkb2]').length== $("[id*='chkb2']: checked").length)