Javascript 在php中,输入Key而不是Tab Key将光标的位置更改为input type
我在php页面中使用以下代码,但我想做的是,当我按Enter键时,光标转到下一个InputTypeText列,而不是Tab键 请让我知道,也可以使用Tab键更改光标位置,但也可以输入键 我喜欢12个输入类型的文本,所以什么是最短的方式来做这件事,抱歉让你们困惑。同时也感谢您在advanced方面的帮助Javascript 在php中,输入Key而不是Tab Key将光标的位置更改为input type,javascript,php,input,tabs,enter,Javascript,Php,Input,Tabs,Enter,我在php页面中使用以下代码,但我想做的是,当我按Enter键时,光标转到下一个InputTypeText列,而不是Tab键 请让我知道,也可以使用Tab键更改光标位置,但也可以输入键 我喜欢12个输入类型的文本,所以什么是最短的方式来做这件事,抱歉让你们困惑。同时也感谢您在advanced方面的帮助 <script> window.onload = function() { document.getElementById('paycode').focus(); } <
<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;?>
再见 这是一般概念:
onkeydown = function(ev){
var e = ev || event;
if(e.keyCode === 13){
return false;
}
// Element.focus();
}
这里的代码太多了。请删除与您的问题不相关的代码,以便我们只看到回答问题所需的最小数量。您必须有一些导致问题的JavaScript。Enter应该提交表单。在大多数浏览器中,使用TAB键是从一个表单元素移动到另一个表单元素的标准方式。更改操作方式只会让用户感到困惑。这是个坏主意。