怎么用回车键切换焦点?

来源:百度知道 编辑:UC知道 时间:2024/06/24 12:10:59
在做网页时,怎么用VBScript脚本语言实现:当用户按下回车键时焦点在几个文本框之间切换?(请高手留下代码,谢谢!)
不行啊,我把你的代码改了一下放到我的代码中不行啊.这是我写的,不能达到预期的效果啊,请高手帮我改改,谢谢!代码是:
<html>
<head><title>回车换键序</title></head>
<body onload='text1.focus' language=vbscript>
<center>
<br><br><br>
<input name=text1 type=text size=30><br><br>
<input name=text2 type=text size=30><br><br>
<input name=text3 type=text size=30><br><br>
<input name=text4 type=text size=30><br><br>
<input name=button1 type=button value=确定>
<SCript for=text(i) event=onkeypress language="VBScript">
for i=1 to 4
if event.keycode=13 then
dim text(i+1) = document.getElementById("text(i+1)") 'text(i+1)是下一个需要得到焦点的input标签
text(i+1).focus()
end if

用event得到当前的动作事件对象

实现input的onkeypress事件
if event.keycode==13 then
dim nextobj = document.getElementById("nextobj")
'nextobj是下一个需要得到焦点的input标签
nextobj.focus()
end if

SendKeys "{Tab}"