下面这段程序能不能简单话写???也就是用循环来写出下面这段代码(或者别的简单方法)???
<SCRIPT LANGUAGE="JavaScript">
<!--
function aa()
{
document.form1.aa.focus();
}
document.onkeyup=ii;
function ii(){
pp=event.keyCode;
ii=parseInt(event.srcElement.id); if(pp==13){
if(ii==1)
{
document.form1.aa.value="A"+document.form1.aa.value;
document.form1.bb.focus();
} if(ii==2)
{
document.form1.bb.value="B"+document.form1.bb.value;
document.form1.cc.focus();
}
if(ii==3)
{
document.form1.cc.value="C"+document.form1.cc.value;
document.form1.dd.focus();
}
if(ii==4)
{
document.form1.dd.value="D"+document.form1.dd.value;
document.form1.aa.focus();
}
}
}//-->
</SCRIPT>
<body onload="aa();">
<form name="form1">
aa<input type="text" id="1" name="aa"><br>
bb<input type="text" id="2" name="bb"><br>
cc<input type="text" id="3" name="cc"><br>
dd<input type="text" id="4" name="dd"><br>
</form>
</body>
<SCRIPT LANGUAGE="JavaScript">
<!--
function aa()
{
document.form1.aa.focus();
}
document.onkeyup=ii;
function ii(){
pp=event.keyCode;
ii=parseInt(event.srcElement.id); if(pp==13){
if(ii==1)
{
document.form1.aa.value="A"+document.form1.aa.value;
document.form1.bb.focus();
} if(ii==2)
{
document.form1.bb.value="B"+document.form1.bb.value;
document.form1.cc.focus();
}
if(ii==3)
{
document.form1.cc.value="C"+document.form1.cc.value;
document.form1.dd.focus();
}
if(ii==4)
{
document.form1.dd.value="D"+document.form1.dd.value;
document.form1.aa.focus();
}
}
}//-->
</SCRIPT>
<body onload="aa();">
<form name="form1">
aa<input type="text" id="1" name="aa"><br>
bb<input type="text" id="2" name="bb"><br>
cc<input type="text" id="3" name="cc"><br>
dd<input type="text" id="4" name="dd"><br>
</form>
</body>
alert(document.onkeyup);//得出的是整个ii()函数的代码。。你想要干什么?
<!--
function aa()
{
document.form1.aa.focus();
}
document.onkeyup=bb;function bb(){
pp=event.keyCode;
ii=parseInt(event.srcElement.id);
if(pp==13){
if(ii==1)
{
document.form1.aa.value="A"+document.form1.aa.value;
document.form1.bb.focus();
} if(ii==2)
{
document.form1.bb.value="B"+document.form1.bb.value;
document.form1.cc.focus();
}
if(ii==3)
{
document.form1.cc.value="C"+document.form1.cc.value;
document.form1.dd.focus();
}
if(ii==4)
{
document.form1.dd.value="D"+document.form1.dd.value;
document.form1.aa.focus();
}
}
}
//-->
</SCRIPT>
<body onload="aa();">
<form name="form1">
aa<input type="text" id="1" name="aa"><br>
bb<input type="text" id="2" name="bb"><br>
cc<input type="text" id="3" name="cc"><br>
dd<input type="text" id="4" name="dd"><br>
</form>
</body>
就是要个这种功能的 不过要简写的
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<SCRIPT LANGUAGE="JavaScript">
<!--
function aa()
{
document.form1.aa.focus();
}
document.onkeyup=ii;
function ii(){
pp=event.keyCode;
ii=parseInt(event.srcElement.id);
var inputs = document.getElementsByTagName("input");
if(pp==13){
if("1,2,3,4".indexOf(ii)!=-1){
inputs[ii-1].value = inputs[ii-1].name.substr(0,1).toUpperCase()+inputs[ii-1].value;
inputs[ii].focus();
}
}
}
//-->
</SCRIPT>
</head>
<body onload="aa();">
<form name="form1">
aa <input type="text" id="1" name="aa"> <br>
bb <input type="text" id="2" name="bb"> <br>
cc <input type="text" id="3" name="cc"> <br>
dd <input type="text" id="4" name="dd"> <br>
</form>
</body></html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional/...>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<SCRIPT LANGUAGE="JavaScript">
<!--
function aa()
{
document.form1.aa.focus();
}
document.onkeyup=ii;
function ii(){
pp=event.keyCode;
ii=parseInt(event.srcElement.id);
var inputs = document.getElementsByTagName("input");
if(pp==13){
if("1,2,3,4".indexOf(ii)!=-1){
inputs[ii-1].value = inputs[ii-1].name.substr(0,1).toUpperCase()+inputs[ii-1].value;
if (ii<4)
{
inputs[ii].focus();
}
}
}
}
//-->
</SCRIPT>
</head>
<body onload="aa();">
<form name="form1">
aa <input type="text" id="1" name="aa"> <br>
bb <input type="text" id="2" name="bb"> <br>
cc <input type="text" id="3" name="cc"> <br>
dd <input type="text" id="4" name="dd"> <br>
</form>
</body></html>
">
aa <input type="text" id="1" name="aa"> <br>
bb <input type="text" id="2" name="bb"> <br>
cc <input type="text" id="3" name="cc"> <br>
dd <input type="text" id="4" name="dd"> <br>
</form>