87,997
社区成员




<!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">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
</head>
<body>
<table id="tbeTest">
<tr>
<th>CheckBox</th>
<th>Number</th>
</tr>
<tr>
<td><input type="checkbox" checked /></td>
<td>1</td>
</tr>
<tr>
<td><input type="checkbox" checked /></td>
<td>1</td>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td>1</td>
</tr>
<tr>
<td><input type="checkbox" checked /></td>
<td>2</td>
</tr>
<tr>
<td><input type="checkbox" checked /></td>
<td>2</td>
</tr>
<tr>
<td><input type="checkbox" checked /></td>
<td>3</td>
</tr>
<tr>
<td><input type="checkbox" checked /></td>
<td>3</td>
</tr>
<tr>
<td><input type="checkbox" checked /></td>
<td>4</td>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td>3</td>
</tr>
</table>
<script type="text/javascript">
<!--
function Element(key, value, rowInd) {
this.Key = key;
this.Value = value;
this.RowIndexes = new Array();
this.RowIndexes.push(rowInd);
}
Element.prototype.AddRowInd = function(rowInd) {
this.RowIndexes.push(rowInd);
};
var checker = {
List: {},
ErrorList: {},
AddElement: function(key, value, rowInd) {
if (this.List[key]) {
if (this.List[key].Value != value
&& this.ErrorList[key] == undefined) {
this.ErrorList[key] = this.List[key];
}
this.List[key].AddRowInd(rowInd);
}
else {
this.List[key] = new Element(key, value, rowInd);
}
},
ShowError: function() {
var msg = "";
for (var p in this.ErrorList)
{
msg += "Error Key: " + p + ", RowIndex: " + this.ErrorList[p].RowIndexes.join("; ") + "\n";
}
if (msg.length > 0)
alert(msg);
}
};
var tbe = document.getElementById("tbeTest");
var row;
for (var i=1, len=tbe.rows.length; i<len; i++)
{
row = tbe.rows[i];
checker.AddElement(row.cells[1].innerHTML, row.cells[0].firstChild.checked, i);
}
checker.ShowError();
//-->
</script>
</body>
</html>
那个大公司 随着楼主 一起秀逗了...