lundi 22 juin 2015

Fame Slide Right to left

i have one checkbox (selectall) and checkboxlist.i bind some item in checkbox list. now i want to validate both checkbox and checkbox list ..like if all checkbox select then selectall should be selected and if any one is deselect then selectall should be deselect. also any one item should be select validate from submit. i try below code....

function CheckAll() {
    var intIndex = 0;
    var rowCount = document.getElementById('<%=chkBindComapany.ClientID %>').getElementsByTagName('input').length;
    for (i = 0; i < rowCount; i++) {
        if (document.getElementById('<%=cbAll.ClientID %>').checked == true) {
            if (document.getElementById('<%=chkBindComapany.ClientID %>' + '_' + i)) {
                if (document.getElementById('<%=chkBindComapany.ClientID %>' + '_' + i).disabled != true)
                    document.getElementById('<%=chkBindComapany.ClientID %>' + '_' + i).checked = true;
            }
        } else {
            if (document.getElementById('<%=chkBindComapany.ClientID %>' + '_' + i)) {
                if (document.getElementById('<%=chkBindComapany.ClientID %>' + '_' + i).disabled != true)
                    document.getElementById('<%=chkBindComapany.ClientID %>' + '_' + i).checked = false;
            }
        }
    }
}

function UnCheckAll() {
    var intIndex = 0;
    var flag = 0;

    var rowCount = document.getElementById('<%=chkBindComapany.ClientID %>').getElementsByTagName('input').length;
    for (i = 0; i < rowCount; i++) {

        if (document.getElementById('<%=chkBindComapany.ClientID %>' + '_' + i).checked == true) {
            flag = 1;

        } else {
            flag = 0;
            break;
        }

    }
    if (flag == 0) {
        document.getElementById('<%=cbAll.ClientID %>').checked = true;
        document.getElementById('lblmsg').innerHTML = "Please select atleast one item.";


    } else {
        document.getElementById('<%=cbAll.ClientID %>').checked = false;
        document.getElementById('lblmsg').innerHTML = "";

    }
}




Aucun commentaire:

Enregistrer un commentaire