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>
<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>
相关文章推荐
- 关于多态和抽象类的一个形象小例子
- c和指针中关于动态分配内存malloc和qsort的一个例子
- 关于SVN配置文件的一个小例子
- 6、关于ctemplate的一个例子
- 一个关于ACE Service Configurator的小例子
- 关于字符串操作的一个小例子(递归实现)
- awk与sed:一个关于多行处理的例子
- 关于Win32的事件和线程的一个例子
- 关于Ext.form.NumberField中输入一个超大数字,失去焦点后变成另一个数字的bug的处理
- 关于java里面Collection包括List,Map等初始化内部匿名类和泛型的一个例子
- 自制简单的Java下载器——来自《Java高级编程》的一个关于线程的例子(带上部分注释)
- 关于Java的RMI编程的一个简单的例子
- 关于ExpandableListView用法的一个简单小例子
- 给大家做一个关于天气的例子
- asp.net2.0(c#)关于画图的一个例子;
- 关于一个简单的策略设计模式的例子
- 关于MSSQL存储过程中使用游标的一个小例子(学习)
- 关于join方法的一个例子
- windows下 python 关于管通道(程序回显)处理的一个小例子
- 自己写的一个关于Linq to Entity 动态查询的例子