您的位置:首页 > 其它

forms 、elements这是关于form的一个例子

2012-08-15 17:04 232 查看
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>js7.html</title>

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">

<meta http-equiv="description" content="this is my page">

<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->

<script type="text/javascript">

//forms 、elements这是关于form的一个例子

function che(object, index)

{

if(object.value.length < 4)

{

document.forms[0].elements[index].focus();

}

else

{

document.forms[0].elements[index+1].focus();

}

}

function cal()

{

var f = document.forms[0].elements;

var st = "";

for(var i = 0; i < 4; i++)

{

st += f[i].value;

}

alert(st);

}

</script>

</head>

<body>

<form action="" method="post">

<input size="4" onkeyup="che(this,0)" type="text">-<input onkeyup="che(this,1)" size="4" type="text">-<input onkeyup="che(this,2)" size="4" type="text">-<input onkeyup="che(this,3)" size="4" type="text">

<input type="button" value="显示" onclick="cal()">

</form>

</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: