您的位置:首页精文荟萃软件资讯 → 具有edit功能的select

具有edit功能的select

时间:2004/10/7 19:16:00来源:本站整理作者:蓝点我要评论(0)


            
             
              
             
            

               
               

            



            1、























2、
function getLeftPostion( theObj )
{
var pos = 0;
while ( theObj != null )
{
pos += theObj.offsetLeft;
//get the Object which contain theObj.
theObj = theObj.offsetParent;
}
return pos;
}
function getTopPostion( theObj )
{
var pos = 0;
while ( theObj != null )
{
pos += theObj.offsetTop;
//get the Object which contain theObj.
theObj = theObj.offsetParent;
}
return pos;
}
function checkVersion()
{
var isBadVersion=true;
var curVer=navigator.appVersion;
var pos=parseInt(curVer.indexOf("MSIE"));
if (pos>=1)
{
var intVer=parseInt(curVer.charAt(pos+5));
if (intVer>=5)
{ isBadVersion=false;}
}
if (isBadVersion)
{
var msg="This page may not be displayed properly:\n"+
" This product requires Microsoft Internet Explorer 5 or later browser only.";
alert(msg);
}
}

//check the browser version
checkVersion();

// the array of comboBoies
theArray = new Array();

function combobox(objId, objHandler)
{
this.comObj = document.all[objId];
this.comObj.selectedIndex = -1;
this.getValue = getValue;
this.doResize = doResize;
this.doChange = doChange;
this.loseFocus = loseFocus;
this.doSelectIdx = doSelectIdx;
this.focus = focus;
this.keyPress = keyPress;
this.change = change;

var strMsg="";

//------------------------------------------------------------------------------------------------------
// create the text object
//------------------------------------------------------------------------------------------------------
var txtObjIdName = objId + "_text";

if (document.all[txtObjIdName] != null)
{
strMsg="The following id: '" + txtObjIdName +"' is used internally by the Combo Box!\r\n"+
"Use of this id in your page may cause malfunction. Please use another id for your controls.";
alert(strMsg);
}

var txtInner = "";

this.comObj.insertAdjacentHTML("afterEnd", txtInner);

this.txtObj = document.all[txtObjIdName];

//------------------------------------------------------------------------------------------------------
// end
//------------------------------------------------------------------------------------------------------

this.beResizing = false;
this.doResize();
theArray[theArray.length] = this;
}

function loseFocus()
{
var theComObj = this.comObj;
var theTxtObj = this.txtObj;
var i;
theComObj.selectedIndex = -1;

if (theTxtObj.value == "")
{
return;
}

var optLen = theComObj.options.length;
for (i=0; i{
var comVal = theComObj.options[i].text;
var txtVal = theTxtObj.value;

if (comVal == txtVal)
{
theComObj.selectedIndex = i;
return;
}
}
}

function doResize()
{
if (!this.beResizing)
{
this.beResizing = true;
this.txtObj.style.display="none";
this.comObj.style.position="static";
this.txtObj.style.posLeft = getLeftPostion(this.comObj);
this.txtObj.style.posTop = getTopPostion(this.comObj) + 1;
this.txtObj.style.posWidth = this.comObj.offsetWidth - 16;
this.txtObj.style.posHeight = this.comObj.offsetHeight;
this.comObj.style.position ="absolute";
this.comObj.style.posLeft = this.txtObj.style.posLeft;
this.comObj.style.posTop = this.txtObj.style.posTop;
this.offWidth = this.comObj.offsetWidth;

var strRect = "rect(0 "+(this.comObj.offsetWidth)+" "+ this.comObj.offsetHeight + " "+(this.txtObj.style.posWidth - 2 )+")";

this.comObj.style.clip = strRect;
this.txtObj.style.display="";
this.beResizing = false;
}
}

function doChange()
{
var idx = this.comObj.selectedIndex;
var opt = this.comObj.options[idx];
this.txtObj.value = opt.text;
this.txtObj.focus();
this.txtObj.select();
this.comObj.selectedIndex=-1;
}

function getValue()
{
return this.txtObj.value;
}

function doSelectIdx(i)
{
var optLen = this.comObj.options.length;

if ((i >=0) && (i < optLen))
{
this.comObj.selectedIndex = i;
this.txtObj.value = this.comObj.options[i].text;
return;
}
this.txtObj.value = "";
}


function focus()
{
this.txtObj.focus();
}

/*resize all combobox when window be resized*/
function resetAllSize()
{
var i;
for (i=0; i < theArray.length; i++)
{
theArray[i].doResize();
}
}
////////////////定位函数开始,我加的///////////////
function keyPress()
{
var txtStr;
var comStr;
var maxInt = 0;
var defInt = 0;
var defJ;
txtStr = this.txtObj.value;
//document.form1.test.value=txtStr;
var j;
for(j=0;j{
comStr = this.comObj.options[j].text;
var m;
for(m=0;m{
if(txtStr.charCodeAt(m) != comStr.charCodeAt(m))
{
maxInt = m;
break;
}
}
if (defInt < maxInt)
{
defInt = maxInt;
defJ = j;
}
}
this.comObj.selectedIndex = defJ;
}

相关阅读 Windows错误代码大全 Windows错误代码查询激活windows有什么用Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新windows 10 rs4快速预览版17017下载错误问题Win10秋季创意者更新16291更新了什么 win10 16291更新内容windows10秋季创意者更新时间 windows10秋季创意者更新内容kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么

文章评论
发表评论

热门文章 360快剪辑怎么使用 36金山词霸如何屏幕取词百度收购PPS已敲定!3

最新文章 微信3.6.0测试版更新了微信支付漏洞会造成哪 360快剪辑怎么使用 360快剪辑软件使用方法介酷骑单车是什么 酷骑单车有什么用Apple pay与支付宝有什么区别 Apple pay与贝贝特卖是正品吗 贝贝特卖网可靠吗

人气排行 xp系统停止服务怎么办?xp系统升级win7系统方电脑闹钟怎么设置 win7电脑闹钟怎么设置office2013安装教程图解:手把手教你安装与qq影音闪退怎么办 QQ影音闪退解决方法VeryCD镜像网站逐个数,电驴资料库全集同步推是什么?同步推使用方法介绍QQ2012什么时候出 最新版下载EDiary——一款好用的电子日记本