// tb:瑕佸悎騫跺崟鍏冩牸鐨勮〃鏍鹼紱stacol錛氬紑濮嬪悎騫跺垪錛沞ndcol:緇撴潫鍚堝茍鍒楋紱bool:鍚堝茍鏂瑰紡錛坱rue浠h〃stacol涓巈ndcol涔嬮棿鍚堝茍錛?nbsp; false浠h〃涓よ竟鍜屽茍錛?num鏍囪鍒楋紙闃叉鏌愪簺淇℃伅鍥犱負鍐呭鐩稿悓鑰屽悎騫躲俥g錛屽鍚嶇浉鍚岃岀紪鍙蜂笉鍚岀殑涓や釜浜猴級
02 |
function uniteTable(tb,stacol,endcol,bool,num) |
03 |
{ var end; |
04 |
var i=0; |
05 |
var j=0; |
06 |
var rowCount=tb.rows.length; // 琛屾暟 |
07 |
var colCount=tb.rows[0].cells.length; // 鍒楁暟 |
08 |
var obj1= null ; |
09 |
var obj2= null ; |
10 |
var n=5; |
11 |
var count= new Array(); |
12 |
for (i=0;i<rowCount;i++){ |
13 |
for (j=0;j<colCount;j++){ |
14 |
tb.rows[i].cells[j].id= "tb__" + i+ "_" +j; |
15 |
} |
16 |
} |
17 |
//鍚堝茍鏍囪鍒楋紝闃叉鏌愪簺淇℃伅鍥犱負鍐呭鐩稿悓鑰屽悎騫訛紙涓嶉渶瑕佹椂錛屽彲浠ヤ笉鐢ㄤ紶鍊鹼級 |
18 |
if ( typeof (num)!= 'undefined' ){ |
19 |
obj1=document.getElementById( "tb__0_" +(num-1).toString()); |
20 |
for ( var t=1;t<rowCount;t++){ |
21 |
obj2=document.getElementById( "tb__" +t.toString()+ "_" +(num-1).toString()); |
22 |
if (obj1.innerHTML==obj2.innerHTML){ |
23 |
obj1.rowSpan++; |
24 |
obj2.parentNode.removeChild(obj2); |
25 |
} else { |
26 |
count[t]=n; //褰撶涓涓漢鐨勫悕縐板悎騫剁粨鏉熸椂錛岀粰count[t]璧嬪煎仛鏍囪 |
27 |
obj1=document.getElementById( "tb__" +t.toString()+ "_" +(num-1).toString()); } |
28 |
} |
30 |
} |
31 |
//濡傛灉endcol鏈畾涔夛紝浠g爜灝嗘渶緇堜竴鍒楀畾涔変負endcol |
32 |
// if(typeof(endcol)=='undefined'){end=colCount;}else{end=endcol} |
33 |
for (i=0;i<colCount;i++){ |
34 |
//bool:鍚堝茍鏂瑰紡錛宼rue浠h〃涓よ竟鍚堝茍錛沠alse浠h〃涓棿鍚堝茍 |
35 |
if (bool){ if (i+1<stacol||i+1>endcol){ continue ;}} |
36 |
else { if (i+1>stacol&&i+1<endcol){ continue ;} } |
37 |
obj1=document.getElementById( "tb__0_" +i.toString()); |
38 |
for (j=1;j<rowCount;j++){ |
39 |
obj2=document.getElementById( "tb__" +j.toString()+ "_" +i.toString()); |
40 |
if ( typeof (count[j])!= 'undefined' ){ |
41 |
if (count[j]!=n){ |
42 |
if (obj1.innerHtml==obj2.innerHtml){ obj1.rowSpan++; |
43 |
obj2.parentNode.removeChild(obj2); } |
44 |
else { obj1=document.getElementById( "tb__" +j.toString()+ "_" +i.toString()); } |
45 |
} else { obj1=document.getElementById( "tb__" +j.toString()+ "_" +i.toString()); } |
46 |
} |
47 |
else { if (obj1.innerHTML==obj2.innerHTML){ |
48 |
obj1.rowSpan++; |
49 |
obj2.parentNode.removeChild(obj2); |
50 |
} |
51 |
else { obj1=document.getElementById( "tb__" +j.toString()+ "_" +i.toString()); } |
52 |
} |
53 |
} |
54 |
} |
55 |
} |