在一个页面中可能有一些hidden控件和一些按钮,另外在这个页面中部有一个表格
在该表格的每一个单元格中有一个文本框用于输入数值,表格的行数和列数不确定
所以文本框的个数也不确定,怎样实现使用左右上下键在这些文本框之间快速移动录入焦点并使文本框中获得焦点时让文本框中的内容select()
在该表格的每一个单元格中有一个文本框用于输入数值,表格的行数和列数不确定
所以文本框的个数也不确定,怎样实现使用左右上下键在这些文本框之间快速移动录入焦点并使文本框中获得焦点时让文本框中的内容select()
解决方案 »
- 关于window.open的问题
- 使用document.location进行跳转后,会出现页面混乱的情况。
- 像flash一样的js导航条(网上看到的大家共享)
- 火狐浏览器中清除cookies的问题
- js前途是否光明?
- 页面loading特效
- easyui 1.3.4 只做长度认证 不做其他的认证
- 求教jquery的hover事件触发问题
- 百思不得其解,IE浏览器不发送cookie,其它浏览器都没问题!
- 请问大家像http://www.dalian.gov.cn/右边公告栏那样的滚动条怎么实现的? 急!
- 急!需要源代码!有些特殊的用左右上下键移动录入焦点的问题!分不够可追加!
- 强制打开窗口页,而非新标签打开页面
为防止和其他插件冲突,给要实现该效果的文本框,多加个class或ID的属性。
<table>
<tr>
<td><input type="text" id="1" onkeydown="chCursor(this, event)" value="1"></td>
<td><input type="text" id="2" onkeydown="chCursor(this, event)" value="2"></td>
<td><input type="text" id="3" onkeydown="chCursor(this, event)" value="3"></td>
</tr>
<tr>
<td><input type="text" id="4" onkeydown="chCursor(this, event)" value="4"></td>
<td><input type="text" id="5" onkeydown="chCursor(this, event)" value="5"></td>
<td><input type="text" id="6" onkeydown="chCursor(this, event)" value="6"></td>
</tr>
<tr>
<td><input type="text" id="7" onkeydown="chCursor(this, event)" value="7"></td>
<td><input type="text" id="8" onkeydown="chCursor(this, event)" value="8"></td>
<td><input type="text" id="9" onkeydown="chCursor(this, event)" value="9"></td>
</tr>
<tr>
<td><input type="text" id="10" onkeydown="chCursor(this, event)" value="10"></td>
<td><input type="text" id="11" onkeydown="chCursor(this, event)" value="11"></td>
<td><input type="text" id="12" onkeydown="chCursor(this, event)" value="12"></td>
</tr>
</table><script language="javascript">
function chCursor(obj, e){
if(e.keyCode == 37){
if((parseInt(obj.id) - 1) < 1)return false;
document.getElementById(parseInt(obj.id) - 1).focus();
}
if(e.keyCode == 38){
if((parseInt(obj.id) - 3) < 1)return false;
document.getElementById(parseInt(obj.id) - 3).focus();
}
if(e.keyCode == 39){
if((parseInt(obj.id) + 1) > 12)return false;
document.getElementById(parseInt(obj.id) + 1).focus();
}
if(e.keyCode == 40){
if((parseInt(obj.id) + 3) > 12)return false;
document.getElementById(parseInt(obj.id) + 3).focus();
}
}
</script>