La copie de code est la suivante:
<! Doctype html public "- // w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<adal>
<meta http-equiv = "contenu-type" contenu = "text / html; charset = gbk" />
<Title> UNT intitulé Document </Title>
</ head>
<body>
<table cellpacing = "0" cellpadding = "0" id = "tab">
<tr>
<td Rowspan = "0"> Zhang San </td>
<td> mâle </td>
<td> 22 </td>
<TD> Mathématiques </td>
<td> 90 </td>
</tr>
<tr>
<td Rowspan = "0"> Zhang San </td>
<td> mâle </td>
<td> 22 </td>
<TD> Mathématiques </td>
<td> 90 </td>
</tr>
<tr>
<td Rowspan = "0"> Zhang San </td>
<TD> Femme </td>
<td> 22 </td>
<td> chinois </td>
<td> 70 </td>
</tr>
<tr>
<td Rowspan = "0"> Zhang San </td>
<TD> Femme </td>
<td> 22 </td>
<td> anglais </td>
<td> 60 </td>
</tr>
<tr>
<td rowspan = "0"> li si </td>
<TD> Femme </td>
<td> 22 </td>
<TD> Mathématiques </td>
<td> 60 </td>
</tr>
<tr>
<td rowspan = "0"> li si </td>
<TD> Femme </td>
<td> 19 </td>
<td> chinois </td>
<td> 60 </td>
</tr>
<tr>
<td rowspan = "0"> wang wu </td>
<td> mâle </td>
<td> 19 </td>
<td> anglais </td>
<td> 60 </td>
</tr>
</ table>
<script type = "text / javascript">
window.onload = function () {
var tab = document.getElementById ("tab");
var col = 0;
Megercell (Tab, Col);
megercell1 (tab, col + 1);
pour (var i = 0; i <tab.Rows.length; i ++) {
// alert (tab.Rows [i] .Cells [0] .getAttribute ("Rowspan"));
}
};
fonction megercell (tab, col) {
Count = 1;
val = "";
pour (var i = 0; i <tab.Rows.length; i ++) {
if (val == tab.Rows [i] .Cells [col] .innerhtml) {
Count ++;
}autre{
if (count> 1) {
de = i - count;
tab.Rows [from] .cells [col] .rowspan = count;
pour (var j = de + 1; j <i; j ++) {
tab.Rows [j] .Cells [col] .style.display = "Aucun";
}
Count = 1;
}
val = tab.Rows [i] .Cells [col] .InnerHtml;
}
}
}
fonction megercell1 (tab, col) {
Count = 1;
val = "";
varWOWSPAN = 0;
pour (var i = 0; i <tab.Rows.length;) {
Rowspan = paSeInt (tab.Rows [i] .Cells [0] .getAttribute ("Rowspan"));
if (Rowspan)
{
pour (var n = 0; n <Rowspan; n ++)
{
if (val == tab.Rows [i] .Cells [col] .innerhtml) {
Count ++;
}autre{
if (count> 1) {
de = i - count;
tab.Rows [from] .cells [col] .rowspan = count;
pour (var j = de + 1; j <i; j ++) {
tab.Rows [j] .Cells [col] .style.display = "Aucun";
}
Count = 1;
}
val = tab.Rows [i] .Cells [col] .InnerHtml;
}
i ++;
}
if (compter> 1)
{
de = i - count;
alert (de + "" + i + "" + count);
tab.Rows [from] .cells [col] .rowspan = count;
pour (var j = de + 1; j <i; j ++) {
tab.Rows [j] .Cells [col] .style.display = "Aucun";
}
}
Count = 1;
val = "";
}
autre
{
i ++;
}
}
}
</cript>
</docy>
</html>