表格自动排序问题,如何用javascript实现,谢谢
以下为测试表格,我想在页面显示的时候,以第三列为准,降序显示,怎么用javascript实现??
<html>
<head>
<title> tree </title>
<meta name= "designer " content= "csdn design team - meizz " />
</head>
<style>
body{
FONT-SIZE: 9pt; PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px;
}
input {
FONT-SIZE: 9pt; height: 15pt; width:50px; cursor: default;
}
table{
font-size: 9pt;
word-break:break-all;
cursor: default;
BORDER: black 1px solid;
background-color:#eeeecc;
border-collapse:collapse;
border-Color:#999999;
align:center;
}
</style>
<body>
<form name= "frm1 " method= "post " action= "/addcontent.jsp ">
<table width= "60% " border= "0 " cellspacing= "0 " cellpadding= "0 " align= "center ">
<tr>
<td width= "24% " align= "center "> <input type= "checkbox " name= "id " value= "15 "> </td>
<td width= "56% "> 后台数据库编程 </td>
<td width= "20% "> 0 </td>
</tr>
<tr>
<td width= "24% " align= "center "> <input type= "checkbox " name= "id " value= "3 "> </td>
<td width= "56% "> 用户体验综合版 </td>
<td width= "20% "> 3 </td>
</tr>
<tr>
<td width= "24% " align= "center "> <input type= "checkbox " name= "id " value= "7 "> </td>
<td width= "56% "> 英语学习和技术翻译 </td>
<td width= "20% "> 1 </td>
</tr>
</table>
</form>
</body>
</html>
------解决方案-------------------- <html>
<head>
<title> tree </title>
<meta name= "designer " content= " " />
</head>
<style>
body{
FONT-SIZE: 9pt; PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px;
}
input {
FONT-SIZE: 9pt; height: 15pt; width:50px; cursor: default;
}
table{
font-size: 9pt;
word-break:break-all;
cursor: default;
BORDER: black 1px solid;
background-color:#eeeecc;
border-collapse:collapse;
border-Color:#999999;
align:center;
}
</style>
<script type=text/javascript>
function sortTable(tableid, col)
{
var table = document.getElementById(tableid);
for (var i = 0; i < ta