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

📄 select.js

📁 本系统的使用可以将工作的部分流程使用计算机的办公自动化处理
💻 JS
字号:
////////////////////////////////////////////////////////////////
//参数说明:
//参数					类型				含义
//theObj:				String 		选择的控件名(多个以逗号隔开)
//theTable:				String 		确定数据库表名
//theValueField:	         	String		下拉列表各列的值(逗号分隔)
//theTextField:			        String		下拉列表各列的的显示值,逗号分隔,如果与值相同就不要填写,个数与值个数对应
//theTitleField:                        String          下拉列表各列的标题
//isHide				String		是否隐藏,默认不隐藏,"Y"为隐藏,与值个数对应
//theWhere:				String		确定检索条件
//theTitle:				String		对话窗口的标题
//itheRelateUrl:	        	int		当前目录相对于lib的层数
////////////////////////////////////////////////////////////////

/**
 *完全控制下拉列表的功能
 */

function SelectActiveX(theObj,theTable,theValueField,theTextField,theTitleField,isHide,theWhere,theTitle,itheRelateUrl)
{
	var rc,i;
	var asRs=new Array();
	var asObj=new Array();

	var Url,x,y,style,theValue,theParams,multiObj;
	var aObjs=new Array();
	var sObj1;
	var sSelTxt="";

	aObjs=theObj.split(",");
	if (aObjs.length>1)
		multiObj='Y';
	else
		multiObj='N';

	sObj1=aObjs[0];

	sSelTxt=window.document.getElementById(sObj1).value;
	if (sSelTxt==null)
		sSelTxt="";

	if (window.document.getElementById(sObj1).className.toLowerCase()=="readonly")
		return;

	var temp="";
	x=new String("");
	y=new String("");

	//得到弹出的位置
	var ele;
	ele=window.event.srcElement;
	if(ele.tagName.toUpperCase()=="IMG" || ele.tagName.toUpperCase()=="DIV")
	{
		y=window.event.screenY;
		x=window.event.screenX-100;
	}else
	{
		x=getLeft(window.event.srcElement)+window.screenLeft+window.event.srcElement.offsetWidth/3;
		y=getTop(window.event.srcElement)+window.screenTop+window.event.srcElement.offsetHeight/2;
	}

	if (theTable==null)
		theTable="";
	theTable=replaceTheChar(theTable,"/"," ");

	if (theValueField==null)
		theValueField="";
	theValueField=replaceTheChar(theValueField,"/"," ");

	if (theTextField==null)
		theTextField="";
	theTextField=replaceTheChar(theTextField,"/"," ");

        if (theTitleField==null)
		theTitleField="";
	theTitleField=replaceTheChar(theTitleField,"/"," ");

	if (theWhere==null)
		theWhere="";
	theWhere=replaceTheChar(theWhere,"/"," ");
	theWhere=replaceTheChar(theWhere,"=","^");
	theWhere=replaceTheChar(theWhere,"#","$");
	theWhere=replaceTheChar(theWhere,"|","/");

	if (theTitle==null)
		theTitle="";
	theTitle=replaceTheChar(theTitle,"/"," ");

	if (isHide==null)
		isHide="";

	if (theTable=="" && theValueField=="" && theTextField=="" && theWhere=="")
	{
		alert("参数无效!\r\n,请检查参数是否正确。");
		return;
	}

	if (itheRelateUrl==null ||itheRelateUrl=="")
		itheRelateUrl=2;
	for (i=1;i<=itheRelateUrl;i++)
		temp+="../";

	Url=temp+"lib/select/selectactivex.jsp";
	theParams="?theTable="+theTable+"&theValueField="+theValueField;
	theParams+="&theTextField="+theTextField+"&theTitleField="+theTitleField;
        theParams+="&isHide="+isHide+"&theWhere="+theWhere;
	theParams+="&theTitle="+theTitle;
	theParams+="&sSelTxt="+sSelTxt;
	theParams+="&multiObj="+multiObj;
	Url+=theParams;
	style="status:no;help:no;dialogWidth:1;dialogHeight:1;dialogTop:"+y+";dialogLeft:"+x;
        //window.open(Url)
	theValue=window.showModalDialog(Url,null,style);

	rc=(theValue==null)?"":theValue;
	asRs=splitValue(rc);
	asObj=theObj.split(",");

    for(i=0;i<Math.min(asRs.length,asObj.length); i++)
    {
		window.document.getElementById(asObj[i]).value=asRs[i];
    }

	return asRs[0];
}
function SelectActiveX1(theObj,theTable,theValueField,theTextField,theTitleField,isHide,theWhere,theTitle,itheRelateUrl)
{
	var rc,i;
	var asRs=new Array();
	var asObj=new Array();

	var Url,x,y,style,theValue,theParams,multiObj;
	var aObjs=new Array();
	var sObj1;
	var sSelTxt="";

	aObjs=theObj.split(",");
	if (aObjs.length>1)
		multiObj='Y';
	else
		multiObj='N';

	sObj1=aObjs[0];
	var obj = sObj1;
	sSelTxt=window.document.getElementById(sObj1).value;
	if (sSelTxt==null)
		sSelTxt="";

	if (window.document.getElementById(sObj1).className.toLowerCase()=="readonly")
		return;

	var temp="";
	x=new String("");
	y=new String("");

	//得到弹出的位置
	var ele;
	ele=window.event.srcElement;
	if(ele.tagName.toUpperCase()=="IMG" || ele.tagName.toUpperCase()=="DIV")
	{
		y=window.event.screenY;
		x=window.event.screenX-100;
	}else
	{
		x=getLeft(window.event.srcElement)+window.screenLeft+window.event.srcElement.offsetWidth/3;
		y=getTop(window.event.srcElement)+window.screenTop+window.event.srcElement.offsetHeight/2;
	}

	if (theTable==null)
		theTable="";
	theTable=replaceTheChar(theTable,"/"," ");

	if (theValueField==null)
		theValueField="";
	theValueField=replaceTheChar(theValueField,"/"," ");

	if (theTextField==null)
		theTextField="";
	theTextField=replaceTheChar(theTextField,"/"," ");

        if (theTitleField==null)
		theTitleField="";
	theTitleField=replaceTheChar(theTitleField,"/"," ");

	if (theWhere==null)
		theWhere="";
	theWhere=replaceTheChar(theWhere,"/"," ");
	theWhere=replaceTheChar(theWhere,"=","^");
	theWhere=replaceTheChar(theWhere,"#","$");
	theWhere=replaceTheChar(theWhere,"|","/");

	if (theTitle==null)
		theTitle="";
	theTitle=replaceTheChar(theTitle,"/"," ");

	if (isHide==null)
		isHide="";

	if (theTable=="" && theValueField=="" && theTextField=="" && theWhere=="")
	{
		alert("参数无效!\r\n,请检查参数是否正确。");
		return;
	}

	if (itheRelateUrl==null ||itheRelateUrl=="")
		itheRelateUrl=2;
	for (i=1;i<=itheRelateUrl;i++)
		temp+="../";

	Url=temp+"lib/select/selectactivex1.jsp";
	theParams="?theTable="+theTable+"&theValueField="+theValueField;
	theParams+="&theTextField="+theTextField+"&theTitleField="+theTitleField;
        theParams+="&isHide="+isHide+"&theWhere="+theWhere;
	theParams+="&theTitle="+theTitle;
	theParams+="&sSelTxt="+sSelTxt;
	theParams+="&multiObj="+multiObj;
	Url+=theParams;
	style="status:no;help:no;dialogWidth:1;dialogHeight:1;dialogTop:"+y+";dialogLeft:"+x;
        //window.open(Url)
	theValue=window.showModalDialog(Url,null,style);

	rc=(theValue==null)?"":theValue;
	if(rc != "")
	window.document.getElementById(obj).value = rc;

	return rc;
}
 function replaceTheChar(theData,theOrginChar,thereplaceTheChar)
 {
 	if (theData=="" || theData==null)
 		return theData;
 	while (theData.indexOf(theOrginChar)!=-1)
 	{
 		theData=theData.replace(theOrginChar,thereplaceTheChar);
 	}

 	return theData;

 }

function splitValue(val)
{
	//返回数组,输入字符串以&nbsp;分离
	var rc,i,j,sp;
	var as=new Array();
	var asRs=new Array();
	rc=val;
	if (rc==null)
		rc=" ";

	sp=","+String.fromCharCode(160,160);
	if(!(rc==""))
	  {
		as=rc.split(sp);
		//j=0;
		for(i=0;i<as.length;i++)
		{
			//if(trimSp(as[i])=="") continue;
			asRs[i]=trimSp(as[i]);
			//j++;
		}
	  }
	return asRs;
}

function trimSp(theData)
{
	var checkStr = theData;
	if (checkStr=="")
		return "";
	var theStrLength=0;
	while (checkStr.charAt(0)==" " || checkStr.charCodeAt(0)==160)
		checkStr=checkStr.substring(1,checkStr.length);
	theStrLength=checkStr.length;
	while (checkStr.charAt(theStrLength-1)==" " || checkStr.charCodeAt(theStrLength-1)==160)
	{
		checkStr=checkStr.substring(0,checkStr.length-1);
		theStrLength=checkStr.length
	}
	return checkStr;
}

function getTop(e)
{
	var t=e.offsetTop;
	while(e=e.offsetParent)
		t+=e.offsetTop;
	return t;
}

function getLeft(e)
{
	var l=e.offsetLeft;
	while(e=e.offsetParent)
		l+=e.offsetLeft;
	return l;
}

⌨️ 快捷键说明

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