As follows:
Copy codeThe Code is as follows:
Function saomiao (event, n)
{
Var code = 0;
Code = event. keyCode; // listen to keyboard input events
If (code = '13') // if you enter the Enter key on the keyboard
{
If (n> 0) // starts to judge the Parameter
{
If (document. getElementById ('logisticsno'). value = '')
{
Alert ('Scan and enter the waybill number! ');
Var r = document. getElementById ('logisticsno ');
R. focus ();
Return false;
}
Else if (document. activeElement. name! = 'Deliver _ money') // name of the element in which document. activeElement. name focuses
{
Var r = document. getElementById ('Deliver _ money ');
R. focus ();
}
Else // if all conditions are met
{
Var r = document. getElementById ('logisticsno ');
R. focus ();
Var f = document. createElement ('form'); // start creating a form
F. action = '/modules/logistics/start. php ';
Document. body. appendChild (f); // Add to body
Var e = document. createElement ('input'); // create a form Element
E. type = 'ddn ';
E. name = 'act ';
E. id = 'act ';
E. value = 'logisticsno ';
F. appendChild (e); // Add to form
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 = 'ddn ';
K. name = 'order _ no ';
K. id = 'order _ no ';
K. value = order_no;
F. appendChild (k );
F. submit (); // form submission
}
}
}
}
<Body onKeyPress = "javascript: saomiao (event, 555);"> // start monitoring keyboard input