1. Table sorting
Table sorting is for tables, regardless of table generation. That is, no matter how the table is generated in the same way as the sort. This is the sort function, very simple.
In ascending and descending order, incoming parameters are required: Obj table name or ID; n row sequence, first column 0
<script>
function Table_sort_asc (obj,n) {
var i,j;
var tab = eval ("document.all." +obj);
if (tab.tagname!= "TABLE") return;
for (i=0;i<tab.rows.length-1;i++)
for (j=i+1;j<tab.rows.length;j++)
if (tab.rows[i].cells[n].innerhtml > Tab.rows[j].cells[n].innerhtml)
Tab.rows[i].swapnode (Tab.rows[j]);
}
function Table_sort_desc (obj,n) {
var i,j;
var tab = eval ("document.all." +obj);
if (tab.tagname!= "TABLE") return;
for (i=0;i<tab.rows.length-1;i++)
for (j=i+1;j<tab.rows.length;j++)
if (Tab.rows[i].cells[n].innerhtml < tab.rows[j].cells[n].innerhtml)
Tab.rows[i].swapnode (Tab.rows[j]);
}
</script>
<script>
Method 1:
function sorttable () {
var arrend = [];
var arrnotbegin = [];
for (i=0 i < document.all.table1.rows.length; i++) {
var oTr = new Object ();
for (J=0 J < document.all.table1.rows (i). Cells.length; j + +) {
var strnode = document.all.table1.rows (i). Cells (j). innertext;
Switch (j)
{
Case 0:
Otr.time = Strnode;
Break
Case 1:
Otr.state = Strnode;
Break
Case 2:
Otr.topic = Strnode;
Break
Default
Break
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service