首页 > 网站 > WEB开发 > 正文

javascript 依次输入自动定焦框

2024-04-27 14:14:57
字体:
来源:转载
供稿:网友

javascript 依次输入自动定焦框

<html> <head> <script type="text/Javascript">     function moveNext(object,index){         if(object.value.length==4){             document.forms[0].elements[index+1].focus();         }     }         function showResult(){         var f=document.forms[0];         var result="";         for(var i=0;i<4;i++){             result+=f.elements[i].value;         }         alert(result);     }</script></head> <body onload="document.forms[0].elements[0].focus();">     <form>         <input type="text" size="3" maxlength="4" onkeyup="moveNext(this,0);">         <input type="text" size="3" maxlength="4" onkeyup="moveNext(this,1);">         <input type="text" size="3" maxlength="4" onkeyup="moveNext(this,2);">         <input type="text" size="3" maxlength="4" onkeyup="moveNext(this,3);">             <input type="button" value="显示" onclick="showResult();">     </form> </body> </html>

image

image

image

image


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表