关闭

弹出查询框的上下键滚动

242人阅读 评论(0) 收藏 举报

    function kp()
   {
    //div_VesselName    
    if(13==window.event.keyCode)
    {
     $('div_VesselName').style.display='none';
     return;
    }    
    if(38==window.event.keyCode)
    {
     return;
    }
    if(40==window.event.keyCode)
    {
     return;
    }    
    SrchVesselName();
   }
   
   function SrchVesselName()
   {
    $('h_vesselNameID').value=0;
   
    var url="../Ajax/SearchVesselName.aspx?";
    var pars="srchText="+$('txtName').value;    
    
    var myAjax = new Ajax.Request(
    url,   
    {
     method: 'post',
     parameters: pars,
     onComplete: showResult
    }); 
   }
   
   function showResult(rep)
   {       
    $('div_VesselName').style.left =parseInt($('navigation1').style.left)+206;    
    $('div_VesselName').style.top =parseInt($('navigation1').style.top)+87;
    $('div_VesselName').style.display='block';
    $('div_VesselName').innerHTML=rep.responseTEXT;
   }
   
   function setVesselName(obj)
   {    
    var s=obj.getElementsByTagName('span');    
    $('txtName').value=s[0].innerHTML;
    $('h_vesselNameID').value=s[1].innerHTML;
    
    $('div_VesselName').style.display='none';
   }
   
   //弹出查询框的上下键滚动
   var focusID=-1;
   var maxID=-1;
   var inputText;
        
   function kd()
   { 
    var txtInput=document.getElementById("txtName");
    var srchDiv=document.getElementById("div_VesselName");
    
    if(srchDiv==null)
    {
     return;
    }
    
    var divs=srchDiv.getElementsByTagName("div");
    var spans=srchDiv.getElementsByTagName("span");
            
    maxID = divs.length-1;
            
    if(maxID==-1)
    {
     return;
    }
            
    if(focusID==-1)
    {
     inputText=txtInput.value;
    }
            
    if(38==window.event.keyCode)
    {
     if(focusID==-1)
     {
      focusID=maxID;
      divs[focusID].style.backgroundColor='#EBF3FB';
      txtInput.value=spans[focusID*2].innerHTML;
      return;
     }
                
     if(focusID==0)
     {
      divs[focusID].style.backgroundColor='#FFFFFF';
      focusID--;
      txtInput.value=inputText;                        
      return;
     }
                
     if(focusID==maxID)
     {  
      divs[focusID-1].style.backgroundColor='#EBF3FB';
      divs[focusID].style.backgroundColor='#FFFFFF';
      focusID--;
      txtInput.value=spans[focusID*2].innerHTML;
      return;
     }
                
     divs[focusID-1].style.backgroundColor='#EBF3FB';               
     divs[focusID].style.backgroundColor='#FFFFFF';
     focusID--;
     txtInput.value=spans[focusID*2].innerHTML;
     return;
    }

    if(40==window.event.keyCode)
    {
     if(focusID==-1)
     {               
      focusID=0;
      divs[focusID].style.backgroundColor='#EBF3FB';
      txtInput.value=spans[0].innerHTML;                      
      return;
     }
                
     if(focusID==0)
     {
      if(maxID==0)
      {
       divs[focusID].style.backgroundColor='#FFFFFF';
       focusID=-1;
       txtInput.value=inputText;
       return;      
      }
      
      divs[focusID].style.backgroundColor='#FFFFFF';
      divs[focusID+1].style.backgroundColor='#EBF3FB';                   
      focusID++;                        
      txtInput.value=spans[2].innerHTML;
      return;
     }
                
     if(focusID==maxID)
     {  
      divs[focusID].style.backgroundColor='#FFFFFF';
      focusID=-1;
      txtInput.value=inputText;
      return;
     }
                
     divs[focusID+1].style.backgroundColor='#EBF3FB';               
     divs[focusID].style.backgroundColor='#FFFFFF';
     focusID++;
     txtInput.value=spans[focusID*2].innerHTML;
     return;
    }
   }

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:82064次
    • 积分:1660
    • 等级:
    • 排名:千里之外
    • 原创:83篇
    • 转载:27篇
    • 译文:1篇
    • 评论:2条
    最新评论