<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    ZhipSoft.com
        冬去春來
            鄭重聲明:本Blog純屬個人學(xué)習(xí)、工作需要,記錄相關(guān)資料。請不要發(fā)表任何有人身攻擊的言論,謝謝!!www.ZhipSoft.com
    posts - 94,comments - 149,trackbacks - 0

    <html>
    <!--函數(shù)說明:可輸入的下拉框列表改進第二版.
    基本參考的阿信的"可輸入下拉框第二版",不過將調(diào)用接口改進了,并允許用戶為控件命名,方便大家在項目中調(diào)用.

    接口說明:
    1: addSelect(obj_id,DefaultValue) 增加空的select控件
    參數(shù)說明:
    obj_id: 控件的id號.
    DefaultValue: 缺省值.
    2: addOption(value,ID) 增加option列表
    參數(shù)說明:
    value: 下拉列表中每一項的值
    ID: 如果存在多個控件,第一個控件的ID值為0,第二個為1,一此類推.


    使用說明:將源代碼中<style>與</style>之間的代碼和<script>與</script>之間的代碼拷貝到你需要調(diào)用該控件的頁面的相應(yīng)位置.然后在需要顯示控件的地方調(diào)用上面兩個接口.
    -->
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>可輸入的下拉框改進第二版</title>
    <style>
    .selectBox{
     border-top-color : #7C7C7C;
     border-left-color : #7C7C7C;
     border-right-color : #D0D0D0;
     border-bottom-color : #D0D0D0;
     border-top-width: 2px;
     border-right-width: 1px;
     border-bottom-width: 1px;
     border-left-width: 2px;
     border-top-style: solid;
     border-right-style: solid;
     border-bottom-style: solid;
     border-left-style: solid;
    }
    .editBox{
     border:0px;
     width:100%;
     cursor:default;
     width:100%;
     padding-top:2px;
     margin-top: 1px;
     margin-right: auto;
     margin-bottom: 1px;
     margin-left: auto;
    }
    .dropdownbutton{
     font-size:12px;
     font-family:webdings;
     color:#000000;
     background-color:#D4D0C8;
     margin:1px;
     cursor:default;
     border-top-width: 2px;
     border-right-width: 2px;
     border-bottom-width: 2px;
     border-left-width: 2px;
     border-top-style: solid;
     border-right-style: solid;
     border-bottom-style: solid;
     border-left-style: solid;
     border-top-color: #E4E4E4;
     border-right-color: #7C7C7C;
     border-bottom-color: #7C7C7C;
     border-left-color: #E4E4E4;
     padding-top: 0px;
     padding-right: 2px;
     padding-bottom: 0px;
     padding-left: 2px;
    }
    .selectContent{
     position:absolute;
     visibility:hidden;
     z-index:1000;
     background-color:#FFFFFF;
     border: 1px solid #000000;
    }
    .selectContent tr{cursor:default}
    .selectContent td{
     font-size:12px;
     font-family:Vendana;
     padding-top: 2px;
     padding-right: 3px;
     padding-bottom: 2px;
     padding-left: 3px;
    }
    .OnFocus{color:#FFFFFF;background-color:#0A246A}
    </style>
    <script language="javascript">
    var ZfSelect=[]
    var CurrentTR=null
    function String.prototype.Trim(){return this.replace(/(^\s*)|(\s*$)/g,'')}//自定義去空格函數(shù)Trim()
    //在第ID個控件下增加option選項
    function addOption(v,ID) {
     
     var i=ID+1;
     //var sv=document.all['ZfSelect_'+ID];
     if(!v.Trim())
     {
     return;
     }
     var tb=document.all['ZfSelect'+i];
    // var test = 'ZfSelect' + i;
    // var tb = document.all[test];
    // alert(tb);
    // alert(document.all['ZfSelect'+i]);
     //tb.insertRow();
     //alert(tb.id);return;
     // tb.rows.length 代表有幾行數(shù)據(jù)
     
     var c=tb.insertRow(tb.rows.length).insertCell();
     // 下拉列表中的顯示值 c.innerHTML
     c.innerHTML=v.Trim();
     
     c.onmouseover=new Function("MouseOver(this)");

     c.onmouseout=new Function("out(this)");

     c.onclick=new Function("MouseClick("+ID+",this)");

     //c.className="td_out";
     v='';
    }
    //增加inpnubox的接口,在頁面中產(chǎn)生一個inputbox控件,下拉列表為空
    function addSelect(name,DefValue) {  
     var i=getSelCount();
      
     var j=i+1;
     //alert("i is:"+i);
     var str='<table id="ZfContainer'+j+'" class="selectBox" border="0" width=100 cellspacing=0 cellpadding=0><tr><td><input name="'+name+'" value="'+DefValue+'" class="editBox" onblur="BoxBlur(this)" onclick="DropDown('+i+')" onkeyup="showTip('+i+')" onmouseenter="selectmove()" onmouseout="selMouseOut(this)"></td>    <td width="1"><span class="dropdownbutton" onmouseover="ButtonOver(this)" onmouseout="ButtonOut(this)" onclick="DropDown('+i+')">6</span></td>  </tr></table>';
     
     document.write(str);
     
      str='<table id="ZfSelect'+j+'" class="selectContent" cellspacing=0 cellpadding=0></table>';
     // str='<table id="ZfSelect'+j+'" class="selectContent" cellspacing=0 cellpadding=0>  <tr onmouseover="MouseOver(this)" onclick="MouseClick('+i+',this)" title="作者:Andy">    <td>'+name+'</td>  </tr></table>';
     //alert(str);
     
        document.write(str); 
     ZfSelect[i]=["ZfContainer"+j,name,"ZfSelect"+j] ;
     

     var s=GetObj(ZfSelect[i][0])

     var ZfContainer=GetObj(ZfSelect[i][2])

     ZfContainer.style.width=s.offsetWidth>ZfContainer.offsetWidth?s.offsetWidth:ZfContainer.offsetWidth
    }

    function getSelCount() { 
     var i=1;  
     while (eval("document.getElementById('ZfContainer"+i+"')")!=null) i++;
     return i-1;
     
    }


    function MouseOver(trObj){
     if(!CurrentTR)CurrentTR=trObj
     CurrentTR.className=""
     trObj.className="OnFocus"
            trObj.title=trObj.innerText
     CurrentTR=trObj;
    }
    //select 選擇框鼠標(biāo)移開時消失
    function selMouseOut(obj)
    {
     with (document.all.zoom_show)
     {
      style.display = "none"
     }
    }
    function ButtonOver(BtnObj){
     BtnObj.style.backgroundColor='#BAB4A7'
    }
    function ButtonOut(BtnObj){
     BtnObj.style.backgroundColor='#D4D0C8'
    }
    // 使text顯示點擊的值
    // 點擊每一項的時候調(diào)用的方法
    function piPei(value) {
    for(i=0;i<document.form.persontype.length;i++) {
    var test = document.form.persontype[i].text;
     if(value==test) {
      document.form.realValue.value=document.form.persontype[i].value;
       
    }
    }

    }
    function MouseClick(Index,trObj){ 
     with(GetObj(ZfSelect[Index][1])){
      value=trObj.innerText; //使text顯示點擊的值
      style.backgroundColor='#0A246A';
      style.color='#FFFFFF';
      focus();
      piPei(value);
    for (g=0;g<document.form.persontype.length;g++)
    {
    //alert("enter...");
     if (document.form.persontype.options[g].text==value)
     {
      
      value=value
      break;
     }
    }
     }
     DropDown(Index)
     
    }
    function GoURL(trObj){
     var url=trObj.getAttribute("url")
     if(url&&url!="")window.open(url)
    }

    // 離開輸入框的時候 失去焦點事件
    function BoxBlur(InputBox){

     with(InputBox.style){backgroundColor="";color=''}
    }

    // 鼠標(biāo)單擊事件 show為true或者false
    // 按下的時候為TRUE,
    function DropDown(Index){
     event.cancelBubble=true;
     
     ZfContainerReset(Index);
     var show=GetObj(ZfSelect[Index][2]).style.visibility=='visible';
     
     GetObj(ZfSelect[Index][2]).style.visibility=show?'hidden':'visible';
     setPosition(Index)
    }
    function document::onclick(){
     for(i=0;i<ZfSelect.length;i++){
     GetObj(ZfSelect[i][2]).style.visibility='hidden';
     with(GetObj(ZfSelect[i][2]))for(j=0;j<rows.length;j++)rows[j].style.display="";
    }
    }
    function window::onresize(){
     for(i=0;i<ZfSelect.length;i++)setPosition(i)
    }
    // 鍵盤按下的時候掉用的事件
    // ZfContainer.rows.length為下拉列表中值的個數(shù) 這里為8和2
    function showTip(Index){
     var inputbox=GetObj(ZfSelect[Index][1])
     var ZfContainer=GetObj(ZfSelect[Index][2])
     var num=0
     
     ZfContainer.style.visibility="visible"
     for(i=0;i<ZfContainer.rows.length;i++){
      if(ZfContainer.rows[i].cells[0].innerText.indexOf(inputbox.value)!=0)ZfContainer.rows[i].style.display="none"
      else {ZfContainer.rows[i].style.display="";num++}
     }
     if(num==0)ZfContainer.style.visibility='hidden'
    }
    function ZfContainerReset(Index){
     var ZfContainer=GetObj(ZfSelect[Index][2])
     for(i=0;i<ZfContainer.rows.length;i++)
     {
     ZfContainer.rows[i].style.display=""
     
     }
     
     if(CurrentTR)CurrentTR.className=""
    }
    // 公用方法
    function setPosition(Index){
     var s=GetObj(ZfSelect[Index][0])
     var ZfContainer=GetObj(ZfSelect[Index][2])
     var l=s.offsetLeft;
     var t=s.offsetTop;

     while(s=s.offsetParent){l+=s.offsetLeft;t+=s.offsetTop}
     with(ZfContainer.style){left=l+1;top=t+GetObj(ZfSelect[Index][0]).offsetHeight}
    }
    //  得到一個對象
    function GetObj(id){

    return document.getElementById(id)


    }

    // 鼠標(biāo)進入該區(qū)域的時候調(diào)用的事件
    // r.text為列表的顯示值

    function selectmove()
    {

     var r
     if(window.event.srcElement.isTextEdit) {
      r=window.event.srcElement.createTextRange();
     }else{
      var el=window.event.srcElement.parentTextEdit;
      //var el=window.event.srcElement.persontype.options[form1.persontype.selectedIndex]
      r=el.createTextRange();
     }
     r.moveToPoint(window.event.x, window.event.y);
     r.expand("word");
     ;
     var str = r.text;
     
     if(str.length > 0 ) {
      with(zoom_show.style) {
       display = "";
       top = event.y + 10;
       left = event.x + 10;
      }
      zoom_show.innerText = str;
     } else {
      zoom_show.style.display = "none";
     }
     
    }

    function bodyclick()
    {
     //alert(name1.value);
    }
    function fuzhi() {
    document.form.realValue.value = document.form.persontype.options[o].value;
    }
    function clickForSubmit()
    {
     var tempValue=document.all["realValue"].value;
     document.location.href="select.html?vaues='"+tempValue+"'";
    }
    </script>
    </head>
    <body onclick="bodyclick()">
    <PRE></PRE>
    <table>
    <form name="form" action="select.html" >

     <div id="zoom_show" style="font-size:12px;color:red;display:none;position:absolute; z-index:2; top:200;background-color: #F7F7F7; layer-background-color: #0099FF; border: 1px #9c9c9c solid;filter:Alpha(style=0,opacity=80,finishOpacity=100);"></div>
    <tr>
     <td><select name="persontype" style="display:none;">
            <option value='-1'>全部</option>
      <option value='1000'>運輸干部運輸干部運輸干部運輸干部運輸干部運輸干部運輸干部</option>
      <option value='1001'>車輛駕駛員</option>
      <option value='1002'>車輛修理工</option>
      <option value='1003'>船艇機電工</option>
      <option value='1004'>油料員</option>
      <option value='1005'>我自己</option>
     </select></td>
    <tr>


    <script language="javascript">
     addSelect("name1","");
     
      for (g=0;g<document.form.persontype.length;g++)
      {

      addOption(document.form.persontype[g].text,0);
     }

    </script>
    <input type="text">
    <br>
    <select name="persontypssse">
                    <option value='-1'>全部</option>
      <option value='1000'>運輸干部運輸干部運輸干部運輸干部運輸干部運輸干部運輸干部</option>
      <option value='1001'>車輛駕駛員</option>
      <option value='1002'>車輛修理工</option>
      <option value='1003'>船艇機電工</option>
      <option value='1004'>油料員</option>
      <option value='1005'>我自己</option>
     </select>
    <br><br><br><br>
     <input type="hidden" name="realValue" value="">
     <input type="button" value="  點擊提交  " onClick="clickForSubmit();">
    </form>
    </table>
    </body>
    </html>



            本Blog純屬個人學(xué)習(xí)、工作需要,記錄相關(guān)資料。請不要發(fā)表任何有人身攻擊的言論,謝謝! www.zhipsoft.cn
    posted on 2007-05-28 15:05 ZhipSoft 閱讀(6434) 評論(3)  編輯  收藏 所屬分類: JavaScript

    FeedBack:
    # re: 可輸入并可以自動檢索的下拉框列表
    2010-01-20 14:30 | ggmm21
    怎樣給select下拉框添加滾動條,并支持鍵盤上、下選擇確定  回復(fù)  更多評論
      
    # dds
    2010-08-18 09:06 | sdfs
    # re: 可輸入并可以自動檢索的下拉框列表[未登錄]
    2011-05-26 18:01 | oscar
    同感,我都想知道如何加滾動條,這個非常重要
      回復(fù)  更多評論
      
    主站蜘蛛池模板: 亚洲av无码专区在线观看亚| 亚洲va久久久噜噜噜久久狠狠| 亚洲午夜精品国产电影在线观看| 久久久精品国产亚洲成人满18免费网站| 免费人成无码大片在线观看| 国产精品亚洲专区无码唯爱网| 国产免费午夜a无码v视频| 国产亚洲Av综合人人澡精品| 国产精品美女自在线观看免费| 粉色视频在线观看www免费| 亚洲精品一级无码鲁丝片| www.xxxx.com日本免费| 亚洲精品蜜桃久久久久久| 免费无码VA一区二区三区| 亚洲人成免费网站| 国产精品公开免费视频| 黄色网址大全免费| 国产亚洲综合网曝门系列| 2021在线观看视频精品免费| 亚洲免费观看网站| 国产午夜影视大全免费观看| 国产精品免费在线播放| 666精品国产精品亚洲| 成年女人午夜毛片免费视频| 免费人成视频在线播放| 亚洲av丰满熟妇在线播放| 中字幕视频在线永久在线观看免费 | 久久亚洲国产视频| 思思re热免费精品视频66| 亚洲AV成人无码网天堂| 国产偷国产偷亚洲清高动态图 | 亚洲今日精彩视频| 成人免费无码大片a毛片| 国产免费福利体检区久久| 67pao强力打造67194在线午夜亚洲| 岛国av无码免费无禁网站| sss日本免费完整版在线观看| 亚洲自偷精品视频自拍| 免费a级毛片无码av| 99久热只有精品视频免费观看17| 亚洲成aⅴ人片久青草影院按摩|