输入Key而不是Tab键可以将光标的位置更改为php中的输入类型


Enter Key instead of Tab Key to change the position of cursor to input type in php

我在php页面中使用以下代码,但我想要的是,当我按下"Enter键"时,光标会转到下一个输入类型(Text)列,而不是"Tab键"请告诉我(也可以用Tab键更改光标位置,但也可以输入键)我有12种输入类型的文本,所以最短的方法是什么,很抱歉让你们感到困惑。同时也感谢您的帮助。

<script>
window.onload = function() {
    document.getElementById('paycode').focus(); 
}
</script>
<style>
#username { background-color:#F0FFF0; }
</style>
<br>
<?php if($serv == '1.EZ Cash'):?>
<center><font size="6"><b><u>Employee PayOut</u></b></font><br><br><table border="1"         cellspacing="0" cellpadding="2"><tr>    <td width="910" align="center" bgcolor="d6d6d6"><font size="5">StoreID&nbsp;&nbsp;</font><font size="5" color="red"><b><?php  $serv=$_POST['serv'];echo $serv ;?></b>
</font></td></tr></table>
<table>
<tr><td width="100" align="center" bgcolor="d6d6d6"><font size="5">Pay Code</font></td>    <td width="100" align="center" bgcolor="d6d6d6"><font size="5">Amount</font></td><td width="146" align="center" bgcolor="d6d6d6"><font size="5">Date</font></td><td width="150" align="center" bgcolor="d6d6d6"><font size="5">Memo</font></td><td width="150" align="center" bgcolor="d6d6d6"><font size="5">Account type</font></td><td width="250" align="center" bgcolor="d6d6d6"><font size="5">Account type</font></td></tr>
</table>
<style>
[required] {
border-color: #88a;
-webkit-box-shadow: 0 0 3px rgba(0, 0, 255, .5);
}
:invalid {
border-color: #e88;
-webkit-box-shadow: 0 0 5px rgba(255, 0, 0, .8);
}
</style>
<form method="post" action="commit.php"><table border = "0" width="330">
<tr><td align = "center"><font size="4">
<td align = "center"><font size="4">
<input type="text" size="25" name="paycode[]" id='paycode'  style="height: 30px; width:   100px" ></td>
<script>
$('input').keydown(function(e) {
if (e.keyCode==13) {
    $(this).next('input').focus();
}
});
</script>
<script type="text/Javascript"  src="Javascript/core.js"></script>
 <td align = "center"><font size="4">
 <input type="hidden" size="25" name="sid[]" id='sid'  style="height: 30px; width:  100px" value="<?php  $serv=$_POST['serv'];echo $serv ;?>"><input type="hidden" size="25"  name="cash[]" id='cash'  style="height: 30px; width: 100px" value=""></td
 </td>
<td align = "center"><font size="4">
<input type="text" size="25" name="amount[]"  id='amount'   style="height: 30px; width:  100px" ></td>
 <td align = "center"><font size="4">
<input type="hidden" size="25" name="check[]" id='check'  style="height: 30px; width:   100px" value=''></td>
<td><input type="date" size="35" name="date[]" style="height: 30px; width: 146px; font-size: 15" min="2010-08-14" max="2020-08-14" value="<?php $serv=$_POST['date']; echo $date;   ?>"/></td>
<td align = "center"><font size="4">
<input type="text" size="25" name="memo[]" id='memo'  style="height: 30px; width: 150px"></td>
<td align = "center"><font size="4"><select name="acc1[]" style="height: 30px; width: 150px">
<option value="10011"  style="background-color: #F8E0F7">&nbsp;10011: EZ Cash</option>   </td></seclect>
<td align = "center"><font size="4"><select name="acc2[]" style="height: 30px; width: 250px">
<option value="66001"  style="background-color: #F8E0F7">&nbsp;66001: EZ Employee Payroll</option></select></td></tr>
<tr><td align = "center"><font size="4">
<td align = "center"><font size="4">
<input type="text" size="25" name="paycode[]" id='paycode'  style="height: 30px; width: 100px"></td>
<td align = "center"><font size="4">
<input type="hidden" size="25" name="sid[]" id='sid'  style="height: 30px; width:   100px" value="<?php  $serv=$_POST['serv'];echo $serv ;?>"></td
</td>
td align = "center"><font size="4">
<input type="text" size="25" name="amount[]" id='amount'  style="height: 30px; width:   100px"></td>
<td align = "center"><font size="4">
<input type="hidden" size="25" name="check[]" id='check'  style="height: 30px; width:  100px" value=''></td>
<td><input type="date" size="35" name="date[]" style="height: 30px; width: 146px; font- size: 15" min="2010-08-14" max="2020-08-14" value="<?php $serv=$_POST['date']; echo $date;   ?>"/></td>
<td align = "center"><font size="4">
<input type="text" size="25" name="memo[]" id='memo'  style="height: 30px; width: 150px"></td>
<td align = "center"><font size="4"><select name="acc1[]" style="height: 30px; width: 150px">
<option value="10011" style="background-color: #F8E0F7">&nbsp;10011: EZ Cash</option>  </td></seclect>
<td align = "center"><font size="4"><select name="acc2[]" style="height: 30px; width: 250px">
<option value="66001" style="background-color: #F8E0F7">&nbsp;66001: EZ Employee Payroll</option></select></td></tr>
<tr><td align = "center"><font size="4">
<td align = "center"><font size="4">
 <input type="text" size="25" name="paycode[]" id='paycode'  style="height: 30px;  width: 100px"></td>
<td align = "center"><font size="4">
<input type="hidden" size="25" name="sid[]" id='sid'  style="height: 30px; width:  100px" value="<?php  $serv=$_POST['serv'];echo $serv ;?>"></td
</td>
<td align = "center"><font size="4">
<input type="text" size="25" name="amount[]" id='amount'  style="height: 30px; width: 100px"></td>
<td align = "center"><font size="4">
<input type="hidden" size="25" name="check[]" id='check'  style="height: 30px; width: 100px" value=''></td>
<td><input type="date" size="35" name="date[]" style="height: 30px; width: 146px; font-size: 15" min="2010-08-14" max="2020-08-14" value="<?php $serv=$_POST['date']; echo $date; ?>"/></td>
<td align = "center"><font size="4">
 <input type="text" size="25" name="memo[]" id='memo'  style="height: 30px; width: 150px"></td>
<td align = "center"><font size="4"><select name="acc1[]" style="height: 30px; width: 150px">
<option value="10011" style="background-color: #F8E0F7">&nbsp;10011: EZ Cash</option>   </td></seclect>
<td align = "center"><font size="4"><select name="acc2[]" style="height: 30px; width: 250px">
<option value="66001" style="background-color: #F8E0F7">&nbsp;66001: EZ Employee Payroll</option></select></td></tr>
<tr><td align = "center"><font size="4">
<td align = "center"><font size="4">
<input type="text" size="25" name="paycode[]" id='paycode'  style="height: 30px; width: 100px"></td>
<td align = "center"><font size="4">
<input type="hidden" size="25" name="sid[]" id='sid'  style="height: 30px; width: 100px" value="<?php  $serv=$_POST['serv'];echo $serv ;?>"></td
</td>
<td align = "center"><font size="4">
<input type="text" size="25" name="amount[]" id='amount'  style="height: 30px; width: 100px"></td>
<td align = "center"><font size="4">
<input type="hidden" size="25" name="check[]" id='check'  style="height: 30px; width: 100px" value=''></td>
<td><input type="date" size="35" name="date[]" style="height: 30px; width: 146px; font-size: 15" min="2010-08-14" max="2020-08-14" value="<?php $serv=$_POST['date']; echo $date; ?>"/></td>
<td align = "center"><font size="4">
<input type="text" size="25" name="memo[]" id='memo'  style="height: 30px; width: 150px"></td>
<td align = "center"><font size="4"><select name="acc1[]" style="height: 30px; width: 150px">
<option value="10011" style="background-color: #F8E0F7">&nbsp;10011: EZ Cash</option>  </td></seclect>
<td align = "center"><font size="4"><select name="acc2[]" style="height: 30px; width: 250px">
<option value="66001" style="background-color: #F8E0F7">&nbsp;66001: EZ Employee Payroll</option></select></td></tr>    
<tr><td align = "center"><font size="4">
<td align = "center"><font size="4">
<input type="text" size="25" name="paycode[]" id='paycode'  style="height: 30px; width: 100px"></td>
<td align = "center"><font size="4">
<input type="hidden" size="25" name="sid[]" id='sid'  style="height: 30px; width: 100px" value="<?php  $serv=$_POST['serv'];echo $serv ;?>"></td
</td>
<td align = "center"><font size="4">
<input type="text" size="25" name="amount[]" id='amount'  style="height: 30px; width: 100px"></td>
<td align = "center"><font size="4">
<input type="hidden" size="25" name="check[]" id='check'  style="height: 30px; width: 100px" value=''></td>
<td><input type="date" size="35" name="date[]" style="height: 30px; width: 146px; font-size: 15" min="2010-08-14" max="2020-08-14" value="<?php $serv=$_POST['date']; echo $date; ?>"/></td>
<td align = "center"><font size="4">
<input type="text" size="25" name="memo[]" id='memo'  style="height: 30px; width: 150px"></td>
<td align = "center"><font size="4"><select name="acc1[]" style="height: 30px; width: 150px">
<option value="10011" style="background-color: #F8E0F7">&nbsp;10011: EZ Cash</option>   </td></seclect>
<td align = "center"><font size="4"><select name="acc2[]" style="height: 30px; width: 250px">
<option value="66001" style="background-color: #F8E0F7">&nbsp;66001: EZ Employee Payroll</option></select></td></tr>    
<tr><td align = "center"><font size="4">
<td align = "center"><font size="4">
<input type="text" size="25" name="paycode[]" id='paycode'  style="height: 30px; width: 100px"></td>
<td align = "center"><font size="4">
<input type="hidden" size="25" name="sid[]" id='sid'  style="height: 30px; width: 100px" value="<?php  $serv=$_POST['serv'];echo $serv ;?>"></td
</td>
<td align = "center"><font size="4">
<input type="text" size="25" name="amount[]" id='amount'  style="height: 30px; width: 100px"></td>
<td align = "center"><font size="4">
<input type="hidden" size="25" name="check[]" id='check'  style="height: 30px; width: 100px" value=''></td>
<td><input type="date" size="35" name="date[]" style="height: 30px; width: 146px; font-size: 15" min="2010-08-14" max="2020-08-14" value="<?php $serv=$_POST['date']; echo $date; ?>"/></td>
<td align = "center"><font size="4">
<input type="text" size="25" name="memo[]" id='memo'  style="height: 30px; width: 150px"></td>
<td align = "center"><font size="4"><select name="acc1[]" style="height: 30px; width: 150px">
<option value="10011" style="background-color: #F8E0F7">&nbsp;10011: EZ Cash</option>  </td></seclect>
<td align = "center"><font size="4"><select name="acc2[]" style="height: 30px; width: 250px">
<option value="66001" style="background-color: #F8E0F7">&nbsp;66001: EZ Employee Payroll</option></select></td></tr>
<tr><td align = "center"><font size="4">
<td align = "center"><font size="4">
<input type="text" size="25" name="paycode[]" id='paycode'  style="height: 30px; width: 100px"></td>
<td align = "center"><font size="4">
<input type="hidden" size="25" name="sid[]" id='sid'  style="height: 30px; width: 100px" value="<?php  $serv=$_POST['serv'];echo $serv ;?>"></td
</td>
<td align = "center"><font size="4">
<input type="text" size="25" name="amount[]" id='amount'  style="height: 30px; width: 100px"></td>
<td align = "center"><font size="4">
<input type="hidden" size="25" name="check[]" id='check'  style="height: 30px; width: 100px" value=''></td>
<td><input type="date" size="35" name="date[]" style="height: 30px; width: 146px; font-size: 15" min="2010-08-14" max="2020-08-14" value="<?php $serv=$_POST['date']; echo $date; ?>"/></td>
<td align = "center"><font size="4">
<input type="text" size="25" name="memo[]" id='memo'  style="height: 30px; width: 150px"></td>
<td align = "center"><font size="4"><select name="acc1[]" style="height: 30px; width: 150px">
<option value="10011" style="background-color: #F8E0F7">&nbsp;10011: EZ Cash</option> </td></seclect>
<td align = "center"><font size="4"><select name="acc2[]" style="height: 30px; width: 250px">
<option value="66001" style="background-color: #F8E0F7">&nbsp;66001: EZ Employee Payroll</option></select></td></tr>
<tr><td align = "center"><font size="4">
<td align = "center"><font size="4">
<input type="text" size="25" name="paycode[]" id='paycode'  style="height: 30px; width: 100px"></td>
<td align = "center"><font size="4">
<input type="hidden" size="25" name="sid[]" id='sid'  style="height: 30px; width: 100px" value="<?php  $serv=$_POST['serv'];echo $serv ;?>"></td
</td>
<td align = "center"><font size="4">
<input type="text" size="25" name="amount[]" id='amount'  style="height: 30px; width:   100px"></td>
<td align = "center"><font size="4">
<input type="hidden" size="25" name="check[]" id='check'  style="height: 30px; width: 100px" value=''></td>
<td><input type="date" size="35" name="date[]" style="height: 30px; width: 146px; font-size: 15" min="2010-08-14" max="2020-08-14" value="<?php $serv=$_POST['date']; echo $date; ?>"/></td>
<td align = "center"><font size="4">
<input type="text" size="25" name="memo[]" id='memo'  style="height: 30px; width: 150px"></td>
<td align = "center"><font size="4"><select name="acc1[]" style="height: 30px; width: 150px">
<option value="10011" style="background-color: #F8E0F7">&nbsp;10011: EZ Cash</option></td></seclect>
<td align = "center"><font size="4"><select name="acc2[]" style="height: 30px; width: 250px">
<option value="66001" style="background-color: #F8E0F7">&nbsp;66001: EZ Employee Payroll</option></select></td></tr>
<tr><td align = "center"><font size="4">
<td align = "center"><font size="4">
<input type="text" size="25" name="paycode[]" id='paycode'  style="height: 30px; width: 100px"></td>
<td align = "center"><font size="4">
<input type="hidden" size="25" name="sid[]" id='sid'  style="height: 30px; width: 100px" value="<?php  $serv=$_POST['serv'];echo $serv ;?>"></td
</td>
<td align = "center"><font size="4">
<input type="text" size="25" name="amount[]" id='amount'  style="height: 30px; width: 100px"></td>
<td align = "center"><font size="4">
<input type="hidden" size="25" name="check[]" id='check'  style="height: 30px; width: 100px" value=''></td>
<td><input type="date" size="35" name="date[]" style="height: 30px; width: 146px; font-size: 15" min="2010-08-14" max="2020-08-14" value="<?php $serv=$_POST['date']; echo $date; ?>"/></td>
<td align = "center"><font size="4">
<input type="text" size="25" name="memo[]" id='memo'  style="height: 30px; width: 150px"></td>
<td align = "center"><font size="4"><select name="acc1[]" style="height: 30px; width: 150px">
<option value="10011" style="background-color: #F8E0F7">&nbsp;10011: EZ Cash</option>   </td></seclect>
<td align = "center"><font size="4"><select name="acc2[]" style="height: 30px; width: 250px">
<option value="66001" style="background-color: #F8E0F7">&nbsp;66001: EZ Employee Payroll</option></select></td></tr>
<tr><td align = "center"><font size="4">
<td align = "center"><font size="4">
<input type="text" size="25" name="paycode[]" id='paycode'  style="height: 30px; width: 100px"></td>
<td align = "center"><font size="4">
<input type="hidden" size="25" name="sid[]" id='sid'  style="height: 30px; width: 100px" value="<?php  $serv=$_POST['serv'];echo $serv ;?>"></td
</td>
<td align = "center"><font size="4">
<input type="text" size="25" name="amount[]" id='amount'  style="height: 30px; width: 100px"></td>
<td align = "center"><font size="4">
<input type="hidden" size="25" name="check[]" id='check'  style="height: 30px; width: 100px" value=''></td>
<td><input type="date" size="35" name="date[]" style="height: 30px; width: 146px; font-size: 15" min="2010-08-14" max="2020-08-14" value="<?php $serv=$_POST['date']; echo $date; ?>"/></td>
<td align = "center"><font size="4">
<input type="text" size="25" name="memo[]" id='memo'  style="height: 30px; width: 150px"></td>
<td align = "center"><font size="4"><select name="acc1[]" style="height: 30px; width: 150px">
<option value="10011" style="background-color: #F8E0F7">&nbsp;10011: EZ Cash</option></td></seclect>
<td align = "center"><font size="4"><select name="acc2[]" style="height: 30px; width: 250px">
<option value="66001" style="background-color: #F8E0F7">&nbsp;66001: EZ Employee Payroll</option></select></td></tr>
<tr><td align = "center"><font size="4">
<td align = "center"><font size="4">
<input type="text" size="25" name="paycode[]" id='paycode'  style="height: 30px; width: 100px"></td>
<td align = "center"><font size="4">
<input type="hidden" size="25" name="sid[]" id='sid'  style="height: 30px; width: 100px" value="<?php  $serv=$_POST['serv'];echo $serv ;?>"></td
</td>
<td align = "center"><font size="4">
<input type="text" size="25" name="amount[]" id='amount'  style="height: 30px; width: 100px"></td>
<td align = "center"><font size="4">
<input type="hidden" size="25" name="check[]" id='check'  style="height: 30px; width: 100px" value=''></td>
<td><input type="date" size="35" name="date[]" style="height: 30px; width: 146px; font-size: 15" min="2010-08-14" max="2020-08-14" value="<?php $serv=$_POST['date']; echo $date; ?>"/></td>
<td align = "center"><font size="4">
<input type="text" size="25" name="memo[]" id='memo'  style="height: 30px; width: 150px"></td>
<td align = "center"><font size="4"><select name="acc1[]" style="height: 30px; width: 150px">
<option value="10011" style="background-color: #F8E0F7">&nbsp;10011: EZ Cash</option>    </td></seclect>
<td align = "center"><font size="4"><select name="acc2[]" style="height: 30px; width: 250px">
<option value="66001" style="background-color: #F8E0F7">&nbsp;66001: EZ Employee Payroll</option></select></td></tr>
<tr><td align = "center"><font size="4">
<td align = "center"><font size="4">
<input type="text" size="25" name="paycode[]" id='paycode'  style="height: 30px; width: 100px"></td>
<td align = "center"><font size="4">
<input type="hidden" size="25" name="sid[]" id='sid'  style="height: 30px; width: 100px" value="<?php  $serv=$_POST['serv'];echo $serv ;?>"></td
</td>
<td align = "center"><font size="4">
<input type="text" size="25" name="amount[]" id='amount'  style="height: 30px; width: 100px"></td>
<td align = "center"><font size="4">
<input type="hidden" size="25" name="check[]" id='check'  style="height: 30px; width: 100px" value=''></td>
<td><input type="date" size="35" name="date[]" style="height: 30px; width: 146px; font-size: 15" min="2010-08-14" max="2020-08-14" value="<?php $serv=$_POST['date']; echo $date; ?>"/></td>
<td align = "center"><font size="4">
<input type="text" size="25" name="memo[]" id='memo'  style="height: 30px; width: 150px"></td>
<td align = "center"><font size="4"><select name="acc1[]" style="height: 30px; width: 150px">
<option value="10011" style="background-color: #F8E0F7">&nbsp;10011: EZ Cash</option>  </td></seclect>
<td align = "center"><font size="4"><select name="acc2[]" style="height: 30px; width: 250px">
<option value="66001" style="background-color: #F8E0F7">&nbsp;66001: EZ Employee Payroll</option></select></td></tr>
</table>
<center>
<br><div><input type="hidden" name="tot" value="<?php echo $total; ?>"> <input      type="hidden" name="stid" value="<?php echo $serv; ?>"><input value="Back" onclick="history.go(-1);" type="button" style = "height:40; width:90">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" style = "height:40; width:90" value="Next"/>
<?php endif;?>

再次拥抱你!

这是一般概念:

onkeydown = function(ev){
  var e = ev || event;
  if(e.keyCode === 13){
    return false;
  }
  // Element.focus();
}