前台合并table单元格

//合并后列
function _w_table_rowspan2(j,k){
     var tb = document.getElementById("process");
     var rowscount = tb.rows.length;
     
     var innerHTML, rowspan, startRow;
     startRow = 0;
     innerHTML = tb.rows[0].cells[j].innerHTML;
     k_innerHTML = tb.rows[0].cells[k].innerHTML;
     rowspan = 1;
     for(var i = 1; i < rowscount; i++) {
         //alert(startRow + parseInt(tb.rows[startRow].cells[0].getAttribute('rowspan')));
         //if(tb.rows[i].cells[j].innerHTML == innerHTML && (j == 0 || i < startRow + parseInt(tb.rows[startRow].cells[0].getAttribute('rowspan')||0))) {
         if(tb.rows[i].cells[j].innerHTML == innerHTML && tb.rows[i].cells[k].innerHTML == k_innerHTML){
             rowspan++;
             tb.rows[i].cells[k].className = "hide";
         }else{
             if(rowspan > 1) tb.rows[startRow].cells[k].rowSpan= rowspan;
               
             startRow = i;
             innerHTML = tb.rows[i].cells[j].innerHTML;
             k_innerHTML = tb.rows[i].cells[k].innerHTML;
             rowspan = 1;
         }
    }
    if (rowspan > 1) tb.rows[startRow].cells[k].rowSpan= rowspan;     
    
}

 

    //合并前列
    function _w_table_rowspan(j){
            var tb = document.getElementById("process");
            var rowscount = tb.rows.length;
            var innerHTML, rowspan, startRow;
                 startRow = 0;
                 innerHTML = tb.rows[0].cells[j].innerHTML;
                 rowspan = 1;
                 for(var i = 1; i < rowscount; i++) {
                     //alert(startRow + parseInt(tb.rows[startRow].cells[0].getAttribute('rowspan')));
                     //if(tb.rows[i].cells[j].innerHTML == innerHTML && (j == 0 || i < startRow + parseInt(tb.rows[startRow].cells[0].getAttribute('rowspan')||0))) {
                     if(tb.rows[i].cells[j].innerHTML == innerHTML){
                         rowspan++;
                         tb.rows[i].cells[j].className = "hide";
                     }else{
                         if(rowspan > 1) tb.rows[startRow].cells[j].rowSpan= rowspan;
                           
                         startRow = i;
                         innerHTML = tb.rows[i].cells[j].innerHTML;
                         rowspan = 1;
                     }
                }
                if (rowspan > 1) tb.rows[startRow].cells[j].rowSpan= rowspan;     
        
      }

posted on 2018-07-03 13:53  master_lu  阅读(179)  评论(0编辑  收藏  举报