这个功能现在不需要了,哪位能告诉我,如何让<select name="sgdw">下拉框能够编辑?即用户可以输入想要的选项,谢谢!

解决方案 »

  1.   

    <HTML><HEAD><TITLE>可编辑下拉框</TITLE>   
        
      <META   content="MSHTML   5.00.2920.0"   name=GENERATOR>   
        
      <META   content=FrontPage.Editor.Document   name=ProgId>   
        
      <META   content="text/html";   http-equiv=Content-Type>   
        
      <STYLE>A   {   
        
      COLOR:   blue;   TEXT-DECORATION:   none   
        
      }   
        
      A:hover   {   
        
      COLOR:   red   
        
      }   
        
      </STYLE>   
        
      </HEAD>   
        
      <BODY>   
        
      <TABLE   align=center   height=100     
        
      style="BACKGROUND-COLOR:   #d2e8ff;   BORDER-BOTTOM:   2px   outset;   BORDER-LEFT:   2px   outset;   BORDER-RIGHT:   2px   outset;   BORDER-TOP:   2px   outset"     
        
      width=250>   
        
      <TBODY>   
        
      <TR>   
        
      <TD   align=middle   colSpan=2   width="100%"><B>可编辑下拉框</B></TD></TR>   
        
      <TR>   
        
      <TD   align=middle   height=30   width="60%">   
      <form   action="test.php"   method="post">   
      <SELECT   name=fason>   
      <option   value="可编辑下拉框"   selected>可编辑下拉框</option>   
      <option   value="作者:阿信">阿信</option>   
      <option   value="1">1</option>   
      <option   value="2">2</option>   
      <option   value="3">3</option>   
      </SELECT>     
      </TD>   
        
      <TD   align=left   height=30   width="40%"><INPUT   onclick="alert(document.getElementsByName('combox_fason')[0].value)"   type=button   value="   取值   ">     
      <input   name="abc"   type="hidden"   onclick="getElementsByName('combox_fason')[0].value">   
      <input   name="add"   type="submit"   value="tijiao">   
      </form>   
      </TD></TR></TBODY></TABLE>   
        
      <SCRIPT   language=javascript>   
      /*   
      作者:fason(阿信)   
      日期:2003-7-1   
      版本:v1.0   
      备注:只作技术交流,如需转载请注明作者等有关信息,多谢合作   
      */   
      function   combox(obj,select){   
      this.obj=obj   
      this.name=select;   
      this.select=document.getElementsByName(select)[0];   
      /*要转换的下拉框*/   
      }   
        
      /*初始化对象*/   
      combox.prototype.init=function(){   
      var   inputbox="<input   name='combox_"+this.name+"'   onchange='"+this.obj+".find()'   "   
      inputbox+="style='position:absolute;width:"+(this.select.offsetWidth-16)+";height:"+this.select.offsetHeight+";left:"+getL(this.select)+";top:"+getT(this.select)+"'>"   
      document.write(inputbox)   
      with(this.select.style){   
      left=getL(this.select)   
      top=getT(this.select)   
      position="absolute"   
      clip="rect(0   "+(this.select.offsetWidth)+"   "+this.select.offsetHeight+"   "+(this.select.offsetWidth-18)+")"   
      /*切割下拉框*/   
      }   
      this.select.onchange=new   Function(this.obj+".change()")   
      this.change()   
        
      }   
      /*初始化结束*/   
        
      ////////对象事件定义///////   
      combox.prototype.find=function(){   
      /*当搜索到输入框的值时,下拉框自动定位*/   
      var   inputbox=document.getElementsByName("combox_"+this.name)[0]   
      with(this.select){   
      for(i=0;i<options.length;i++)   
      if(options[i].text.indexOf(inputbox.value)==0){   
      selectedIndex=i   
      this.change();   
      break;   
      }   
      }   
      }   
        
      combox.prototype.change=function(){   
      /*定义下拉框的onchange事件*/   
      var   inputbox=document.getElementsByName("combox_"+this.name)[0]   
      inputbox.value=this.select.options[this.select.selectedIndex].text;   
      with(inputbox){select();focus()};   
      }   
      ////////对象事件结束///////   
        
      /*公用定位函数(获取控件绝对坐标)*/   
      function   getL(e){   
      var   l=e.offsetLeft;   
      while(e=e.offsetParent)l+=e.offsetLeft;   
      return   l   
      }   
      function   getT(e){   
      var   t=e.offsetTop;   
      while(e=e.offsetParent)t+=e.offsetTop;   
      return   t   
      }   
      /*结束*/   
      </SCRIPT>   
        
        
        
      <SCRIPT   language=javascript>   
      var   a=new   combox("a","fason")   
      a.init()   
      var   b=new   combox("b","ttt")   
      b.init()   
      /*作用方法:   
      var   obj=new   combox(var1,var2)   
      var1:新生成的combox变量(如:a)   
      var2:原下拉框的name   
      obj.init():对象初始化   
      注意:后台取值时用combox_var2进行取值   
      */   
      </SCRIPT>   
        
        
        
      <P   align=right>作者:<A     
        
      href="http://fason.nease.net/">fason(阿信)</A>欢迎交流!</P></BODY></HTML>