function checkAll(custId){
var id;
if(document.getElementById(custId).checked == true){
<%for (CustomerGroup custGroup : customerGroupList) {%>
if(custId==<%=custGroup.getCustomerGroupId()%>){
<%List<Account> list = accountDelegate
.findAccountEntityByGroupId(custGroup
.getCustomerGroupId());
for (Account account : list) {%>
id=<%=account.getAccountId()%>
document.getElementById(id).checked=true;
<%}%>
}
<%}%>
}else {
<%for (CustomerGroup custGroup : customerGroupList) {%>
if(custId==<%=custGroup.getCustomerGroupId()%>){
<%List<Account> list2 = accountDelegate
.findAccountEntityByGroupId(custGroup
.getCustomerGroupId());
for (Account account : list2) {%>
id=<%=account.getAccountId()%>
document.getElementById(id).checked=false;
<%}%>
}
<%}%>
}
}
Here I have passed custId as a id of checkbox.Problem here is if(document.getElementById(custId).checked == true
each time this condition will evaluate to false and thus control goes on else part.
so how can i know wether checkbox is cheched or not ?.
The
checkedproperty is what you need to use to verify if a checkbox is checked: