文本框输入值从数据库中查询出匹配相等的数据,记忆文本框

JS:

 

   document.οnkeydοwn=setCode;
function setCode(){
            if (event.keyCode==40)
            {
                var srcElem = document.activeElement
                var testval = srcElem.name;
                if(testval=="TextAdmissionDiagnosis")
                {
                   document.getElementById("lsBoxInfo").focus();
                }
            }
            if(event.keyCode==13)
            {

                    event.returnValue   =   false;
                    var srcElem = document.activeElement
                    var testval = srcElem.name;
                    if(testval=="lsBoxInfo")
                    {
                       getData();
                    }
            }
}
   
      function getSelect(a) {
               if(a.value=="")
                    return;
               var CheckIdList=MedicalTwo_AddMedicalTwo.GetLC_RememberCode(a.value).value;
                if(CheckIdList.length != 0)
                {
                                            document.getElementById("lsBoxInfo").style.display="block";
                                      var slt = document.getElementById("lsBoxInfo");
                                  
                                            for (i = slt.options.length - 1; i >= 0; i--) {
                                                 slt.options.remove(i);
                                            }
                                                        for (i = 0; i < CheckIdList.length; i++) {
                                                            option = new Option();
                                                            option.text = CheckIdList[i].split('@')[0];
                                                            option.value = CheckIdList[i].split('@')[1];
                                                            slt.options.add(option);
                                                        }
                }else
                {
                      document.getElementById("lsBoxInfo").style.display="none";
                }

           
         
      }
            function getData()
            {
          
                var province=document.getElementById("lsBoxInfo");
                var pindex = province.selectedIndex;
                var pValue = province.options[pindex].value;
                var pText  = province.options[pindex].text;                                               
                document.getElementById("TextAdmissionDiagnosis").innerText=pText;
                document.getElementById("lsBoxInfo").style.display="none";

               
            }
            function Setoubl()
            {
                var srcElem = document.activeElement
                var testval = srcElem.name;
                if(testval != "TextAdmissionDiagnosis" && testval!="lsBoxInfo")
                {
                    document.getElementById("lsBoxInfo").style.display="none";
                }
            }

 

Html:

     <td class="right_chaxun_bai" align="left" colspan="3" style="height: 24px; position:relative;">
                                                         <div id="divPropertyInfo" style="position:absolute;  z-index:20; ; width:100%; left: 0px; top: 0px;">
                                                                <input id="TextAdmissionDiagnosis" type="text" runat="server" style="width: 90%"  class="right_chaxun_input"   AutoComplete="off" />
                                                         </div>
                                                         <select id="lsBoxInfo" runat="server" style="display: none;position:absolute;  z-index:20; top:20px; width:90%;" multiple="true" ></select>
                                                     
                                                </td>

事件:

 

         this.TextAdmissionDiagnosis.Attributes.Add("onblur", "Setoubl();");
            this.TextAdmissionDiagnosis.Attributes.Add("onkeyup", "getSelect(this);");

            this.lsBoxInfo.Attributes.Add("onblur", "Setoubl();");
            //双击
            this.lsBoxInfo.Attributes.Add("ondblclick", "getData();")

 

转载于:https://www.cnblogs.com/ajax2008/archive/2011/09/09/2172243.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值