如何響應鍵盤事件?
菜鳥請教:如題,我將光標停留在一TextBox中,回車後光標停至TabIndex+1的位置? 问题点数:20、回复次数:1Top
1 楼astra1(Hyperion)回复于 2006-03-02 20:24:55 得分 0
在页面中类似如此,还没找到更好的方法
<script>
function checkEnter(element)
{
if(event.keyCode==13)
{
var i;
for(i=0;i<document.all.length;i++)
if(document.all(i).tabIndex&&document.all(i).tabIndex==element.tabIndex+1)
{
document.all(i).focus();
break;
}
if(i<document.all.length)
event.returnValue=false;
}
}
</script>
<asp:textbox id="TextBox1" onkeypress="checkEnter(this)" TabIndex=1 runat="server"></asp:textbox>
<asp:textbox id="TextBox2" onkeypress="checkEnter(this)" runat="server" TabIndex=3 ></asp:textbox>
<select tabindex=2 onkeypress="checkEnter(this)">
<option>ff</option>
</select>Top




