⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datatable.js

📁 医院信息系统(Hospital Information System
💻 JS
字号:
function  jtrim(s)
{
    var  i,b=0,e=s.length;
    for(i=0;i<s.length;i++)
        if(s.charAt(i)!=' '){b=i;break;}
    if(i==s.length)
        return  "";
    for(i=s.length-1;i>b;i--)
        if(s.charAt(i)!=' '){e=i;break;}
    return  s.substring(b,e+1);
}

function init(){
	var showType=document.getElementById("pageShowType").value;
	var curMenuID=document.getElementById("menuID").value;
	var userID=parent.document.getElementById("userID").value;
	showType=encodeURI(showType).replace(/\%/g,"!");
	parent.document.frames["upButton"].location.href="buttonShowAction.do?showType="+showType+"&pagename=upbutton"+"&menuID="+curMenuID+"&userID="+userID;
	parent.document.frames["downButton"].location.href="buttonShowAction.do?showType="+showType+"&pagename=downbutton"+"&menuID="+curMenuID+"&userID="+userID;
	
	//span标签中分别有列名,排序用的上箭头和下箭头
	var allColumnNameSpan=document.getElementsByTagName("SPAN");
	for(var i=0;i<allColumnNameSpan.length;i++){
		//查找orderColumn隐藏域中的值和哪列的列名相匹配,若匹配说明该列有排序操作
		if(allColumnNameSpan[i].innerText==document.getElementById("orderColumn").value){
			var curSortSpan=allColumnNameSpan[i].parentNode.getElementsByTagName("SPAN");
			//确定是升序还是降序操作,以显示不同的箭头
			if(document.getElementById("orderKind").value=="asc"){
				curSortSpan[1].style.display="inline";
			}else {
				curSortSpan[2].style.display="inline";
			}
		}
	}
}

function columnSort(curTD){
	//得到用户所选择的标题列
	var curTDSpan=curTD.getElementsByTagName("SPAN");
	var myColumnName=curTDSpan[0].innerText;
	//alert(myColumnName);
	//得到其中的上下箭头,上箭头表示升序,下箭头表示降序
	var arrowUP=curTDSpan[1];
	var arrowDown=curTDSpan[2];
	//如果此时上下箭头都没有显示,说明未排序,默认先进行升序
	if(arrowUP.style.display=="none"&&arrowDown.style.display=="none"){
		arrowUP.style.display="inline";
		arrowDown.style.display="none";
		document.getElementById("orderKind").value="asc";
	}
	//如果此时上箭头有显示,说明已进行了升序,那么要变为降序
	else if(arrowUP.style.display=="inline"){
		arrowUP.style.display="none";
		arrowDown.style.display="inline";
		document.getElementById("orderKind").value="desc";
	}
	//如果此时下箭头有显示,说明已进行了降序,那么要变为升序
	else if(arrowDown.style.display=="inline"){
		arrowUP.style.display="inline";
		arrowDown.style.display="none";
		document.getElementById("orderKind").value="asc";
	}
	//在隐藏域中保存要排序的列
	document.getElementById("orderColumn").value=myColumnName;
	//提交到showDataAction.do
	document.getElementsByName("deleteActionForm")[0].action="showDataAction.do";
	document.getElementsByName("deleteActionForm")[0].submit();
}

//填写关键字的值
function fillKeyValue(curTR){
	var tableKeyNames=decodeURI(document.getElementById("keyNames").value.replace(/\!/g,"%"));
	var contentTable=document.getElementById("table1");
	//得到表格的标题行
	var titleRow=contentTable.rows[0];
	var colNumber;
	//从标题行找出关键字所在列的序号
	for(var i=1;i<titleRow.childNodes.length;i++){
		//alert(titleRow.cells[i].firstChild.innerText+","+tableKeyNames);
		if(jtrim(titleRow.cells[i].firstChild.innerText)==jtrim(tableKeyNames)){
			colNumber=i;	
		}
	}
	//按照关键字所在列的序号,从所选择的行中取得关键字的值
	document.getElementById("keyValues").value=jtrim(curTR.cells[colNumber].innerText);
}

//双击某一数据行之后显示详细信息
function showItemDeteils(curTR){
	//document.getElementById("saveStatus").value="4";
	document.getElementsByName("deleteActionForm")[0].action="modifyAction.do";
	document.getElementsByName("deleteActionForm")[0].submit();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -