Repeater 中CheckBox的相关操作

来源:互联网 发布:windows 10 for phone 编辑:程序博客网 时间:2024/06/01 19:56

function SelectAllCheckBox() { var oElements = Main.document.getElementsByTagName("INPUT"); var strCheckBoxName; var blnBool = false; var i; for(i = 0; i < oElements.length; i++) { strCheckBoxName = oElements[i].id; if (IsCheckBox(oElements[i]) && IsMatch(strCheckBoxName)) { if (oElements[i].checked == false) { blnBool = true; break; } } } for(i = 0; i < oElements.length; i++) { strCheckBoxName = oElements[i].id; if (IsCheckBox(oElements[i]) && IsMatch(strCheckBoxName)) { oElements[i].checked = blnBool; } } CheckBoxClick(); return false; }

 

function CheckBoxClick() { var strCheckBoxName = ""; var strFlag = ""; var i = 0; var blnFlag = true; var oElements = Main.document.getElementsByTagName("INPUT"); for(i = 0; i < oElements.length; i++) { strCheckBoxName = oElements[i].id; strFlag = strCheckBoxName.substring(strCheckBoxName.length-1,strCheckBoxName.length); if (IsCheckBox(oElements[i]) && IsMatch(strCheckBoxName)) { if (strFlag == "0" && oElements[i].checked == true) { blnFlag = false; break; } if (strFlag == "1" && oElements[i].checked == true && Main.<%# chkAgain.ClientID %>.checked == true) { blnFlag = false; break; } } } Main.<%# btnPrint.ClientID %>.disabled = blnFlag; }

 

function IsMatch(strCheckBoxName) { var myReg = /rptSearchResult__(ctl[1-9][0-9]*)(_chkBox[1-9][0-9]*)/; if(myReg.test(strCheckBoxName)) { return true; } else { return false; } }

 

function IsCheckBox(chkCheckBox) { if (chkCheckBox.type == 'checkbox') { return true; } else { return false; } }

 

function SaveCheckBoxState() { var strCheckBoxName = ""; var strFlag = Main.<%# txtCurrentPageCount.ClientID %>.value; var i = 0; var oElements = Main.document.getElementsByTagName("INPUT"); for(i = 0; i < oElements.length; i++) { strCheckBoxName = oElements[i].id; if (IsCheckBox(oElements[i]) && IsMatch(strCheckBoxName)) { if (oElements[i].checked == true) { strFlag += "1"; } else { strFlag += "0"; } } } return strFlag; }

 

function UpdateCheckBoxState(intIndex) { var strValue = Main.<%# txtCheckBoxState.ClientID %>.value; var strTemp = SaveCheckBoxState(); return strValue.replace(strValue.substr(intIndex,strTemp.length),strTemp); }

 

function PageChange() { var strValue = Main.<%# txtCheckBoxState.ClientID %>.value; var strTemp = Main.<%# txtCurrentPageCount.ClientID %>.value; var intIndex = strValue.indexOf(strTemp); if (intIndex == -1) { Main.<%# txtCheckBoxState.ClientID %>.value += SaveCheckBoxState(); } else { Main.<%# txtCheckBoxState.ClientID %>.value = UpdateCheckBoxState(intIndex); } return true; }