上一篇:一个显示计算机时间的钟表的程序代码 >>
客户端JS表格排序---摘自微软.
*表格排序
*t:表格体.例:myTable.tBodies[0]
*iRowEnd:第几行停止排序.例:myTable.tBodies[0].rows.length-1
*fReverse:升序,降序.例:true(升)false(降)
*iColumn:第几列需要排序.例 4
*/
function insertionSort(t, iRowEnd, fReverse, iColumn)
{
var iRowInsertRow, iRowWalkRow, current, insert;
for ( iRowInsert = 0 + 1 ; iRowInsert <= iRowEnd ; iRowInsert++ )
{
if (iColumn)
{
if( typeof(t.children[iRowInsert].children[iColumn]) != "undefined")
textRowInsert = t.children[iRowInsert].children[iColumn].innerText;
else
textRowInsert = "";
}
else
{
textRowInsert = t.children[iRowInsert].innerText;
}
for ( iRowWalk = 0; iRowWalk <= iRowInsert ; iRowWalk++ )
{
if (iColumn)
{
if(typeof(t.children[iRowWalk].children[iColumn]) != "undefined")
textRowCurrent = t.children[iRowWalk].children[iColumn].innerText;
else
textRowCurrent = "";
}
else
{
textRowCurrent = t.children[iRowWalk].innerText;
}
//
// We save our values so we can manipulate the numbers for
// comparison
//
current = textRowCurrent;
insert = textRowInsert;
// If the value is not a number, we sort normally, else we evaluate
// the value to get a numeric representation
//
if ( !isNaN(current) || !isNaN(insert))
{
current= eval(current);
insert= eval(insert);
}
else
{
current=current.toLowerCase();
insert= insert.toLowerCase();
}
if ( ( (!fReverse && insert < current)
|| ( fReverse && insert > current) )
&& (iRowInsert != iRowWalk) )
{
eRowInsert = t.children[iRowInsert];
eRowWalk = t.children[iRowWalk];
t.insertBefore(eRowInsert, eRowWalk);
iRowWalk = iRowInsert; // done
}
}
}
}
参考:有3个例子.各个不赖.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndude/html/dude07232001.asp
下一篇:函数整理(变量和转换函数) >>
相关文章:
- · 用DHTML来模拟实现下拉菜单
- · javascript动态增加、删除、填充表格内容。
- · 最完美的JS万年历(一)
- · 最完美的JS万年历(二)
- · 最完美的JS万年历(三)
- · 用JS定制IE工具栏按钮
- · 看看我写的.和这里样式差不多.不过一样好用哟.滑动时还有音乐.用的qq的音乐
- · 妙用VBScript自制IE工具栏按钮(转)
- · js有几个缺陷。combox1.doSelectIdx(-1)我看不用调用了。
- · 层不能跨框架(包括TEXTAREA)显示的解决办法
- · 罗亭的可输入下拉框的解密简化版.
- · IE里的探索之浏览器概览
- · IE里的探索之向标准上下文相关菜单里添加条目
- · IE里的探索之添加浏览器栏
- · IE里的探索之添加工具条按钮(2)
- · IE里的探索之添加工具条按钮(1)
- · IE里的探索之创建具有良好行为的自定义元素
- · IE里的探索之定制浏览器好助手(上1)
- · IE里的探索之定制浏览器好助手(上2)
- · IE里的探索之定制浏览器好助手(中1)
- · IE里的探索之定制浏览器好助手(下)
- · IE里的探索(想定制自己的IE的可以看一看)
- · 这个object还有其他几种用法.现在贴了给大家.
- · 自动关闭窗口,方法总结
- · 这个脚本可以使你方便得获得各网站的连接速度
- · 列表框操作函数集合
- · 常用javascript函数(一)
- · 控制输出字符串的长度,可以区别中英文
- · 常用javascript函数(二)
- · 如何判断客户端浏览器的脚本js.vbs功能是否被禁止,通过隐藏域实现
- · 台湾的两篇文章,看看也好:唯讀的表單文字輸入項
- · Creating CSS Buttons (一)
- · Creating CSS Buttons (二)
- · 用javascript实现浮点数的截取小数位数,并四舍五入
- · three trim function(javascript)
- · 用ASP将javascript代码写入客户端执行的一种简易方法。。。
- · Trim Function in javascript
- · java分页源码
