<script language="javascript" type="text/javascript">
var HdnChkIds = '';
var ImgPathList = '';
function GetChkValues(chk, ImgPath) {
var ImgPaths = replaceAll(ImgPath, '~', '\\');
if (chk.checked == true) {
ImgPathList = document.getElementById('<%= HdnImgPaths.ClientID %>').value += ImgPaths + '^';
HdnChkIds = document.getElementById('<%= HdnChkBoxValues.ClientID %>').value += parseInt(chk.id) + 1 + ',';
var Ids_array = document.getElementById('<%= HdnChkBoxValues.ClientID %>').value.split(",");
document.getElementById('<%= LblSelectedImgs.ClientID %>').style.display = "block";
document.getElementById('<%= LblSelectedImgsShow.ClientID %>').style.display = "block";
document.getElementById('<%= LblCheckImgs.ClientID %>').style.display = "block";
document.getElementById('<%= LblCheckImgsCountShow.ClientID %>').style.display = "block";
var Sorting = HdnChkIds.substring(0, HdnChkIds.length - 1).split(',');
document.getElementById('<%= LblSelectedImgsShow.ClientID %>').innerText = Sorting.sort(sortNumber);
document.getElementById('<%= LblCheckImgsCountShow.ClientID %>').innerText = Ids_array.length - 1;
}
else
{
HdnChkIds = document.getElementById('<%= HdnChkBoxValues.ClientID %>').value.replace(parseInt(chk.id) + 1 + ',', "");
document.getElementById('<%= HdnChkBoxValues.ClientID %>').value = HdnChkIds;
var Ids_array = document.getElementById('<%= HdnChkBoxValues.ClientID %>').value.split(",");
ImgPathList = document.getElementById('<%= HdnImgPaths.ClientID %>').value.replace(ImgPaths + '^', "");
document.getElementById('<%= HdnImgPaths.ClientID %>').value = ImgPathList;
if (Ids_array.length - 1 != 0) {
var Sorting = HdnChkIds.substring(0, HdnChkIds.length - 1).split(',');
document.getElementById('<%= LblSelectedImgsShow.ClientID %>').innerText = Sorting.sort(sortNumber);
document.getElementById('<%= LblCheckImgsCountShow.ClientID %>').innerText = Ids_array.length - 1;
}
else {
document.getElementById('<%= LblSelectedImgsShow.ClientID %>').innerText = "0";
document.getElementById('<%= LblCheckImgsCountShow.ClientID %>').innerText = "0";
document.getElementById('<%= LblSelectedImgs.ClientID %>').style.display = "none";
document.getElementById('<%= LblSelectedImgsShow.ClientID %>').style.display = "none";
document.getElementById('<%= LblCheckImgs.ClientID %>').style.display = "none";
document.getElementById('<%= LblCheckImgsCountShow.ClientID %>').style.display = "none";
}
}
}
function checkedAll(checkAllState, cbGroup) {
var Status = 0;
// Check that the group has more than one element
if (checkAllState.checked == true) {
Status = 1;
}
if (cbGroup.length > 0) {
// Loop through the array
for (i = 0; i < cbGroup.length; i++) {
cbGroup[i].checked = checkAllState.checked;
}
if (Status == 1) {
document.getElementById('<%= HdnImgPaths.ClientID %>').value = document.getElementById('<%= HdnChkAllImgPaths.ClientID %>').value;
HdnChkIds = document.getElementById('<%= HdnChkBoxValues.ClientID %>').value = document.getElementById('<%= HdnChkAllImgIds.ClientID %>').value;
var Sorting = HdnChkIds.substring(0, HdnChkIds.length - 1).split(',');
document.getElementById('<%= LblSelectedImgs.ClientID %>').style.display = "block";
document.getElementById('<%= LblSelectedImgsShow.ClientID %>').style.display = "block";
document.getElementById('<%= LblCheckImgs.ClientID %>').style.display = "block";
document.getElementById('<%= LblCheckImgsCountShow.ClientID %>').style.display = "block";
document.getElementById('<%= LblSelectedImgsShow.ClientID %>').innerText = Sorting.sort(sortNumber);
document.getElementById('<%= LblCheckImgsCountShow.ClientID %>').innerText = document.getElementById('<%= TotalCountImgsShow.ClientID %>').innerText;
}
if (Status == 0) {
document.getElementById('<%= LblSelectedImgsShow.ClientID %>').innerText = "0";
document.getElementById('<%= LblCheckImgsCountShow.ClientID %>').innerText = "0";
document.getElementById('<%= LblSelectedImgs.ClientID %>').style.display = "none";
document.getElementById('<%= LblSelectedImgsShow.ClientID %>').style.display = "none";
document.getElementById('<%= LblCheckImgs.ClientID %>').style.display = "none";
document.getElementById('<%= LblCheckImgsCountShow.ClientID %>').style.display = "none";
document.getElementById('<%= HdnImgPaths.ClientID %>').value = "";
document.getElementById('<%= HdnChkBoxValues.ClientID %>').value = "";
}
}
else {
// Single element so not an array
cbGroup.checked = checkAllState.checked;
}
}
function replaceAll(txt, replace, with_this) { return txt.replace(new RegExp(replace, 'g'), with_this); }
function sortNumber(a, b) { return a - b; }
</script>
No comments:
Post a Comment