selectitem.js

来自「一个较好的公务员管理系统软件源代码」· JavaScript 代码 · 共 77 行

JS
77
字号

var theIndex=0;
function SelectValue()
{
 var index;
 index=theSel.selectedIndex;
 if (index>=0)
  {
   returnValue=theSel.options(index).value;
   window.close();
  }
 }

function enabledBtn()
{
 var index;
 index=theSel.selectedIndex;
 if (index>=0)
  document.getElementById("btnOk").disabled=0;
}

function getData()
{
	if (event.keyCode==13 || event.which==13)
		SelectValue();
}

function ModifySize()
{
  info.innerText="";
  document.getElementById("selTxt").contentEditable =true;
  self.dialogHeight=(theSel.offsetHeight+13)/13;
  self.dialogWidth=(theSel.offsetWidth)/14.2;
  selTxt.size=parseInt(theSel.offsetWidth/7.2);
  selTxt.maxLength=selTxt.size;
}

function getRelateData(theObj)
{
	var tempStr="",theFindStr="";
	var theLength=0;
	var isFind=false,isBack=false;

	if (event.keyCode==8 || event.which==8)
		theIndex=0;

	if (theIndex==null)
		theIndex=0;
	if (event.keyCode==13 || event.which==13)
		SelectValue();
	else
	{
		tempStr=theObj.value;
		theLength=tempStr.length;
		if (tempStr=="" || theLength==0)
		{
			theIndex=0;
			isFind=false;
			document.getElementById("theSel").options(0).selected=true;
			return;
		}
		while (!isFind && theIndex<document.getElementById("theSel").length && theIndex>=0)
		{
			theFindStr=document.getElementById("theSel").options(theIndex).text;
			if (theFindStr.toUpperCase().indexOf(tempStr.toUpperCase())>=0)
			{
				isFind=true;
				document.getElementById("theSel").options(theIndex).selected=true;
			}
			if (isBack && theIndex>0)
				theIndex--;
			else
				theIndex++;
		}
		theIndex=document.getElementById("theSel").selectedIndex;
	}
}

⌨️ 快捷键说明

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