# re: 如何实现文本框焦点自动跳转及通过回车键提交表单 2004-05-26 15:34 aierong
<script language="vbscript">
<!--
Sub document_onkeydown
if window.event.keyCode=13 then
window.event.keyCode=9
end if
End Sub
//-->
</script>
function nextFocus(thisForm,thisElement,thisEvent){
txtVal=thisElement.value;
txtName=thisElement.name;
frmName=thisForm.name;
frmLength=parseInt(document.forms.length);
var go = 0;
var nxtElmnt = "";
isNetscape=(document.layers);
eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;
which = String.fromCharCode(eventChooser).toLowerCase();
if(which > -1 && which < 10){
if(which != 1 && which != 2 && which != 3 && which != 4 && which != 5 && which != 6 && which != 7 && which != 8 && which != 9 ){
go =1;
} }
for(p=0;p < frmLength;p++){
if(document.forms[p].name==frmName){
elemntLength=parseInt(document.forms[p].elements.length)
for(i=0;i<elemntLength;i++){
if(document.forms[p].elements.name == txtName)
{j=i+8;
if(document.forms[p].elements[j] !=null){
nxtElmnt=document.forms[p].elements[j].name;
}
if(document.forms[p][nxtElmnt] == null ){
go=0;}
if(document.forms[p][nxtElmnt] != null){
if (document.forms[p][nxtElmnt].name.substring(0,3) == "qty" ){
if( go==1){
document.forms[p][nxtElmnt].focus();
break;
}
} } }} }
}
go =0;
}
呃?方法可以向下╋但?0?也?跳下去╋0也跟著跳。
onkeypress="nextFocus(this.form,this,event)"
怎么使?0呃?嫔?不跳呢?