如下所示:
复制代码 代码如下:
function saomiao(event,n)
{
     var code=0;
     code=event.keyCode;//监听键盘输入事件
     if(code=='13')//如果键盘输入回车键
     {
          if(n>0)//开始判断参数
          {
               if(document.getElementById('logisticsno').value=='')
          {
           alert('请扫描输入运单号!');
                     var r=document.getElementById('logisticsno');
                     r.focus();
           return false;
                   }
             else if(document.activeElement.name!='deliver_money')//document.activeElement.name焦点所在的元素名
             {
                     var r=document.getElementById('deliver_money');
                     r.focus();       
               }
             else//如果所有条件都满足
             {
                 var r=document.getElementById('logisticsno');
                     r.focus();
                     var f=document.createElement('form');//开始新建表单
                     f.action='/modules/logistics/start.php';
                     document.body.appendChild(f);//添加至body

                     var e=document.createElement('input');//新建表单元素
                     e.type='hidden';
                     e.name='act';
                     e.id='act';
                     e.value='logisticsno';
                     f.appendChild(e);//添加至表单

                     var data_id=0;
                     var g=document.getElementsByName("orderdataid_no[]");
                     var h=0;
                     for(var h=0;h<g.length;h++)
                     {
                      data_id=g[h].value;
                          }

                     var order_no=0;
                     var gg=document.getElementsByName("order_no[]");
                     var hh=0;
                     for(var hh=0;hh<gg.length;hh++)
                     {
                      order_no=gg[hh].value;
                     }

                     var k=document.createElement('input');
                     k.type='hidden';
                     k.name='order_no';
                     k.id='order_no';
                     k.value=order_no;
                     f.appendChild(k);

                     f.submit();//表单提交
                   }  
               }   
      }
     }
<body onKeyPress="javascript:saomiao(event,555);">//开始监控键盘输入
 

标签:
javascript,焦点

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com