当前位置: 移动技术网 > IT编程>开发语言>.net > 下拉菜单输入,根据输入内容自动定位

下拉菜单输入,根据输入内容自动定位

2018年10月10日  | 移动技术网IT编程  | 我要评论

除铁器厂家,日本直购,租车论坛

下拉菜单支持输入,并根据输入内容自动定位:

参考:演员发表于 10/23/2001 8:58:16 am 的文章 “罗亭的可输入下拉框的解密简化版.”,在此特别感谢相关人等。

本文为这个下拉框增加了一点小小的功能:输入能够定位在已有的选择框内。还有一个缺点,各位给改改:输入的时候不能够自动拉开选择框,怎么办?

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: "+
            " 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! "+
           "use of this id in your page may cause malfunction. please use another id for your controls.";
        alert(strmsg);
    }

    var txtinner = "<input type=text id=" + txtobjidname + " name=" + txtobjidname + " onblur=" + objhandler + ".losefocus() " + " onkeyup=" + objhandler + ".keypress()" +  " onchange=" + objhandler + ".keypress()" + " style=display: none; position: absolute value= >";

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网