获得下拉列表框的焦点后,怎样使用快捷键(如F8)选中下拉列表框(selet)的选项,而代替鼠标点击,选中各个选项。用快捷键F8(不用默认的方向键上下移动选中各选项)选中选项,最好能够使select弹出下拉列表(达到和鼠标同样的效果)

解决方案 »

  1.   

    帅帅的宝宝作品必定全部代码,做了一天了!请速给分,谢谢配合
    <!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <style>
    .content{
        font-size:13px;
    text-indent :8px;
    }
    #a{
        float:left;
    width:30px;
    text-align:center;
    border:0;
    position:relative; bottom:-2px;
    position:relative; left:3px;
    font-size:13px;
    }
    #b{
        position:relative; left:3px;
    }
    .cs1{
        border:1px solid blue; width:55px;}
    .cs2{
        border:1px solid black;
    width:55px;

    </style>
    <title>无标题文档</title>
    </head>
    <body>
    <div class="cs1" id="cs1">
    <input id="a" type="text" value="123" align="center" size="20" unselectable="on" \>
    <div id="b"><img src="1\button1.gif" \></div>
    </div>
    <div class="cs2" id="cs2" style="display:none">
    <div class="content" id="1" style="background-color:RGB(49,106,197);border:1px dashed #999999;color:#FFFFFF;">123</div>
    <div class="content" id="2" >456</div>
    <div class="content" id="3" >789</div>
    </div>
    <script type="text/javascript">document.getElementById("a").onkeydown = function(){
                                                 if(event.keyCode == 119){
         //document.getElementById("a").value=document.getElementById("1").innerText;
         document.getElementById("cs2").style.display="block";  
                                                }
                                                 else if(event.keyCode == 40){
                                                     for(i=1;i<=2;i++){
                                                         if(eval("document.getElementById('" + i + "')").style.backgroundColor == "rgb(49,106,197)"){
                                                              with(eval("document.getElementById('" + i + "')").style){
                                                                 background = "";color = "";border=""; 
                      }
                  with(eval("document.getElementById('" + parseInt(i+1) + "')").style){
                                                                 backgroundColor = "rgb(49,106,197)";color = "#FFFFFF";border="1px dashed #999999"; 
                      }
                      break;
                 }
                                                     }
        
     }
                                                 else if(event.keyCode == 38){
                                                     for(i=3;i>=2;i--){
                                                         if(eval("document.getElementById('" + i + "')").style.backgroundColor == "rgb(49,106,197)"){
                                                              with(eval("document.getElementById('" + i + "')").style){
                                                                 background = "";color = "";border=""; 
                      }
                  with(eval("document.getElementById('" + parseInt(i-1) + "')").style){
                                                                 backgroundColor = "rgb(49,106,197)";color = "#FFFFFF";border="1px dashed #999999"; 
                      }
                      break;
                 }
                                                     }
        
     }
     else if(event.keyCode == 13){
                                                     for(i=1;i<=3;i++){
                                                         if(eval("document.getElementById('" + i + "')").style.backgroundColor == "rgb(49,106,197)"){
         document.getElementById("a").value = eval("document.getElementById('" + i + "')").innerText;
     document.getElementById("cs2").style.display="none";
     break;
     }
         }
     }
                                              };

    </script> 
    </body>
    </html>
      

  2.   

    说明:获得焦点后(鼠标和Tab都可以),按F8弹出下拉框,上下键选择,回车确定!
      

  3.   

    快捷键是 alt+上箭头或下箭头
      

  4.   

    发现一个问题,你没法看到我的图片!因为图片是特殊的,要图片可以+我msn:[email protected]