<!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" />
<title>无标题文档</title>
<script language="javascript">
function Gototimu(kk){
window.alert(kk);
}
</script>
</head>
<body> 到<input type="text" name="order" style="width:35px;font-weight: bold;" onKeyUp="if(event.code==13)Gototimu(document.all.order.value);" >

</body>
</html>
可以用回车来触发跳转表明输入完成了

解决方案 »

  1.   

    要么就用onblur事件?或者当按键是非数字的时候alert()?
      

  2.   

    我看到下面的效果,就是用的onKeyUp
    他支持输入1位或2为位数字注意是:修改第————题 这里
    地址是:http://www.jsyks.com/mnks.asp
    不知道他是怎么实现的,他的JS源代码也看不到期待高手出现。
      

  3.   

    她也是每次触发的呀,输入1到第1题,再输入2到第12题
    要么,做一个延迟加载,if(tid==null) clearTimeout(tid);
    setTimeout("do()",500);这样即时按第二个键时就不会触发第1次的
      

  4.   


    <!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" />
    <title>无标题文档</title>
    <script language="javascript">
    var tid = null;
    function Gototimu(kk){
      if(tid != null) clearTimeout(tid);
      tid = setTimeout("doit('" + kk + "')", 500);
    }
    function doit(kk){
      window.alert(kk);
    }
    </script>
    </head>
    <body> 到<input type="text" name="order" style="width:35px;font-weight: bold;" onKeyUp="Gototimu(document.all.order.value);" >

    </body>
    </html>
      

  5.   

    <!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" />
    <title>无标题文档</title>
    <script language="javascript">
    var to=null;
    function Gototimu(tb){
    if(tb.value=="") return;
    if(to)clearTimeout(to);
    var div=document.getElementById(tb.value);
    if(div)
    {
      to=setTimeout("ShowSel('"+tb.value.replace("'","\'")+"')",300);
      }
      else
        tb.value='';
    }
    function ShowSel(id)
    {
      var divs=document.getElementsByTagName("div");
      for(var i=0;i<divs.length;i++)
      {
        divs[i].style.display="none";
      }
      document.getElementById(id).style.display='';
    }
    </script>
    </head>
    <body> 到<input type="text" name="order" style="width:35px;font-weight: bold;" onKeyUp="Gototimu(this);" >

    <div id="1">第1题</div>
    <div id="2" style="display:none">第2题</div>
    <div id="3" style="display:none">第3题</div>
    <div id="4" style="display:none">第4题</div>
    <div id="5" style="display:none">第5题</div>
    <div id="6" style="display:none">第6题</div>
    <div id="7" style="display:none">第7题</div>
    <div id="8" style="display:none">第8题</div>
    <div id="9" style="display:none">第9题</div>
    <div id="10" style="display:none">第10题</div>
    <div id="11" style="display:none">第11题</div>
    <div id="12" style="display:none">第12题</div>
    <div id="13" style="display:none">第13题</div>
    </body>
    </html>
      

  6.   

    到<input type="text" name="order" style="width:35px;font-weight: bold;" onKeyUp="setTimeout('Gototimu('+document.all.order.value+')',100);" >

    那这样是不是也行.