js dynamic delete a row

来源:互联网 发布:软件可靠性分析方法 编辑:程序博客网 时间:2024/06/13 05:09

<%//Deletes the selected rows from the objects array and redraws the grid%>
         function fndeletecriteria() {
         var tarr = new Array();
         var recordSelected = false;
         for(var i=0;i<farr.length;i++) {
         if( ! eval("document.filterfrm.chkrow" + i).checked) {
         tarr[tarr.length] = farr[i]
         }else{
         recordSelected = true;
         }
         }
         
         if(!recordSelected) {
         alert("<gtl:content service='jsLabel' contentID='Filter_noSelectted'/>");
         }
         farr = tarr;
         fndrawgrid();
         document.filterfrm.selfield.focus();
         }
         <%//Clears the rows from the objects array and redraws the grid%>
         function fnclear() {
         farr = new Array()
         document.filterfrm.reset();
         fndrawgrid()
         }

 

 

<%//function for drawing the grid%>
         function fndrawgrid() {
         var str = new String();
         str = str + "<table width='100%' border='0' cellspacing='0' cellpadding='0'>"
         str = str + "<tr>"
         str = str + "<td bordercolor='#FFFFFF' bgcolor='#FFFFFF'>&nbsp;</td>"
         str = str + "</tr>"
         str = str + "<tr>"
         str = str + "<td bordercolor='#FFFFFF' bgcolor='#FFFFFF'>&nbsp;</td>"
         str = str + "</tr>"
         str = str + "<tr>"
         str = str + "<td bordercolor='#FFFFFF' bgcolor='#FFFFFF'>&nbsp;</td>"
         str = str + "</tr>"
         str = str + "<tr>"
         str = str + "<td bordercolor='#FFFFFF' bgcolor='#FFFFFF'>"
         str = str + "<table width='90%' border='0' cellspacing='0' cellpadding='0' align='center'>"
         str = str + "<tr>"
         str = str + "<td bordercolor='#FFFFFF' bgcolor='c0c0c0'>"
         str = str + "<table width='100%' border='0' cellspacing='1' cellpadding='0' align='center' bordercolor='#CCCCCC'>"
         str = str + "<tr bgcolor=f1f1f1 height='30px' align='center'>"
         str = str + "<td width='6%' align='center' height='18'>&nbsp; </td>"
         str = str + '<td width="23%" height="18"><b><gtl:content contentID="Filter_grid_Field" /></b></td>'
         str = str + '<td width="22%" height="18"><b><gtl:content contentID="Filter_grid_operator" /></b></td>'
         str = str + '<td width="23%" height="18"><b><gtl:content contentID="Filter_grid_value" /></b></td>'
         str = str + '<td width="26%" height="18"><b><gtl:content contentID="Filter_grid_clause" /></b></td>'
         str = str + "</tr>"
         if(farr.length == 0) {
         }else {
         for(var i=0;i<farr.length;i++) {
         str = str + "<tr align='center' bgcolor=ffffff style='font-style:Tohoma;font-size:13'>"
         str = str + "<td width='6%' align='center'>"
         str = str + "<input type='checkbox' name='chkrow" + i + "' value='on'>"
         str = str + "</td>"
         str = str + "<td width='23%' align='center'>" + farr[i].ffieldname + "</td>"
           //str = str + "<td width='22%' align='center'>" + farr[i].foperator + "</td>"
           if(farr[i].foperator == "LIKE" && farr[i].fvalue.charAt(0)!="%" && farr[i].fvalue.charAt(farr[i].fvalue.length-1)=="%"){
               str = str + "<td width='22%' align='center'>STARTS WITH</td>"
         } else if(farr[i].foperator == "LIKE" && farr[i].fvalue.charAt(0)=="%" && farr[i].fvalue.charAt(farr[i].fvalue.length-1)!="%"){
               str = str + "<td width='22%' align='center'>ENDS WITH</td>"
         } else if(farr[i].foperator == "LIKE" && farr[i].fvalue.charAt(0)=="%" && farr[i].fvalue.charAt(farr[i].fvalue.length-1)=="%"){
               str = str + "<td width='22%' align='center'>CONTAINS</td>"
         } else if(farr[i].foperator == "NOT LIKE" && farr[i].fvalue.charAt(0)!="%" && farr[i].fvalue.charAt(farr[i].fvalue.length-1)=="%"){
               str = str + "<td width='22%' align='center'>DOES NOT STARTS WITH</td>"
         } else if(farr[i].foperator == "NOT LIKE" && farr[i].fvalue.charAt(0)=="%" && farr[i].fvalue.charAt(farr[i].fvalue.length-1)!="%"){
               str = str + "<td width='22%' align='center'>DOES NOT ENDS WITH</td>"
         } else if(farr[i].foperator == "NOT LIKE" && farr[i].fvalue.charAt(0)=="%" && farr[i].fvalue.charAt(farr[i].fvalue.length-1)=="%"){
               str = str + "<td width='22%' align='center'>DOES NOT CONTAINS</td>"
         } else{
               str = str + "<td width='22%' align='center'>" + farr[i].foperator + "</td>"
         } 
         
         if(farr[i].foperator == "IS NULL" || farr[i].foperator == "IS NOT NULL") {
               str = str + "<td width='23%' align='center'>&nbsp;</td>"
         }
         else{

         if(farr[i].fvalue.charAt(0)!="%" && farr[i].fvalue.charAt(farr[i].fvalue.length-1)=="%" ){
         str = str + "<td width='23%' align='center'>" + farr[i].fvalue.substr(0,farr[i].fvalue.length-1) + "</td>"
         } else if( farr[i].fvalue.charAt(0)=="%" && farr[i].fvalue.charAt(farr[i].fvalue.length-1)!="%" ){
           str = str + "<td width='23%' align='center'>" + farr[i].fvalue.substr(1,farr[i].fvalue.length-1) + "</td>"
         } else if( farr[i].fvalue.charAt(0)=="%" && farr[i].fvalue.charAt(farr[i].fvalue.length-1)=="%" ){
           str = str + "<td width='23%' align='center'>" + farr[i].fvalue.substr(1,farr[i].fvalue.length-2) + "</td>"
         }
         else{
         str = str + "<td width='23%' align='center'>" + farr[i].fvalue + "</td>"
         }
         }
         str = str + "<td width='26%' align='center'>" + farr[i].fclause + "</td>"
         str = str + "</tr>"
         }
         }
         str = str + "</table>"
         str = str + "</td>"
         str = str + "</tr>"
         str = str + "</table>"
         str = str + "</td>"
         str = str + "</tr>"
         str = str + "</table>"
         document.all['dynatext'].innerHTML = str;
         
         } 

原创粉丝点击