【发布时间】:2014-09-16 01:42:31
【问题描述】:
我在我的 php 页面中使用以下代码,但我想要的是,当我按“Enter 键”时,光标会转到下一个输入类型(文本)列而不是“Tab 键” 请让我知道(也可以使用 Tab 键更改光标位置,但也可以使用 Enter 键) 我喜欢 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 </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"> 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"> 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"> 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"> 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"> 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"> 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"> 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"> 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"> 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"> 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"> 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"> 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"> 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"> 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"> 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"> 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"> 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"> 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"> 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"> 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"> 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"> 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"> 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"> 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"> <input type="submit" style = "height:40; width:90" value="Next"/>
<?php endif;?>
再次感谢您!
【问题讨论】:
-
这里的代码太多了。请删除与您的问题无关的代码,以便我们只看到回答问题所需的最少代码。
-
您必须有一些导致问题的 JavaScript。
Enter应该提交表单。 -
在大多数浏览器中,使用 TAB 键是从一个表单元素移动到另一个表单元素的标准方式。改变它的完成方式只会让你的用户感到困惑。这是个坏主意。
标签: javascript php input tabs enter