javascript写的表格排序
/**
* 表格排序(单个表格,降序)
* @example
* <code>
* <table is_sort="1">
* <tr>
* <th><a href="javascript:void(0)" mce_href="javascript:void(0)" onclick="table_sort(0, 0)">field1</a></th>
* <th><a href="javascript:void(0)" mce_href="javascript:void(0)" onclick="table_sort(1, 1, 1)">field2</a></th>
* </tr>
*
* <!-- 此tr不会参与排序 -->
* <tr>
* <th>...</th>
* <td>...</td>
* </tr>
*
* <!-- 此tr参与排序 is_sort属性 sort_val属性 -->
* <tr is_sort="1">
* <th sort_val="val1">...</th>
* <th sort_val="val2">...</th>
* </tr>
* ...
* </table>
* </code>
* @param int index 需要排序的列(从0开始)
* @param int is_desc 是否降序
* @param int is_int 是否需要将排序值转换成int类型
* @return void
*/
function table_sort(index, is_desc, is_int)
{
$('table[is_sort=1]').each(function(){
var i=0, j=0, this_table = this, is_change=false, tr = null, tmp = null, sort_val1=0, sort_val2=0, pattern=/^0+/;
$('tr[is_sort=1]').each(function(){
j = 0;
tr = this;
$('tr[is_sort=1]', this_table).each(function(){
if (j>=i)
{
is_change = false;
//格式化排序值
sort_val1 = $($('th,td', tr).get(index)).attr('sort_val');
sort_val2 = $($('th,td', this).get(index)).attr('sort_val');
if (is_int)
{
if (sort_val1!='0')
{
sort_val1 = parseInt(sort_val1.replace(pattern, ''));
}
if (sort_val2!='0')
{
sort_val2 = parseInt(sort_val2.replac
相关文档:
原帖地址:http://www.followman.com/bbs/Topic-B11-T262.aspx
JavaScript动态响应ATL事件
相关讨论:http://topic.csdn.net/t/20061012/21/5078729.html
重
点:脚本传过来的对象是IDispatch接口,应该用IDispatch::Invoke来调用。如果传过来的是个function,那么DISPID
为0,如果是个对象,那么要先用GetIDsOfNames得 ......
制作Javascript弹出窗口技巧九则
1、最基本的弹出窗口代码
其实代码非常简单:
< SCRIPT LANGUAGE="javascript">
< !--
window.open ("page.html")
--
>
< /SCRIPT>
因为这是一段Javascript代码,所以它们应该放在< SCRIPT LANGUAGE="javascript">之间。 ......
基本上全部加了注释,一行一注....呵呵
<!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>数组排序</title>
<mce:style type="text/css"&g ......
javascript集锦
javascript数组操作汇总
javascript动态创建form表单 和 节点控制说明
动态读取
javascript:function ctys(_ctag){
ctys1=document.createElement(_ctag);
document.body.appendChild(ctys1);
return ctys1
};
newE1=ctys('<TEXTAREA id=www>');
newE1.cols='150';
newE1.rows='30 ......
禁止页面刷新的javascript代码
当用户向数据库提交数据后,往往由于点击了F5刷新页面,造成数据的重复提交,很容易造成数据库数据混乱.
如果屏蔽了刷新按钮,二次提交的可能性会小很多!
下面是禁止页面刷新的javascript代码:
document.onkeydown = function()
{
if(ev ......