<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>formUtil.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">
</head>
<script type="text/javascript">
//innerText和innerHTML,outerText和outerHTML的区别
//<div><b>Hello</b> world</div>
//innerText是指Hello
//innerHTML是指<b>Hello</b> world
//outerText是指Hello world
//outerHTML是指<div><b>Hello</b> world</div>
//如何获得表单的引用
//第一种:var oForm = document.getElementById("form1");
//第二种:var oForm = document.forms[0];
//第三种:var oForm = documnet.forms["form1"];
//表单中字段的获得
//第一种:var eText = oForm.elements[0];
//第二种:var eText = oForm.elements["name"];
//第三种:var eText = oForm.textbook; 这个是根据元素的name属性获得
//第四种:var eText = oForm["sname"];
//document.getElementById();
//表单中字段的共性
//disabled,form(表单中的元素获得当前form),blur(),focus()
//focus到第一个非hidden字段
var FormUtil = new Object;
FormUtil.focusFirst = function(){
if(document.forms.length>0){
for(var i=0;i<document.forms[0].elements.length;i++){
var oField = document.forms[0].elements[i];
if(oField.type!="hidden"){
oField.focus();
//选择文本
//oField.select();
return;
}
}
}
};
//给文本字段加上select();
FormUtil.setTextboxes = function() {
var colInputs = document.getElementsByTagName("input");
var colTextAreas = document.getElementsByTagName("textarea");
for (var i=0; i < colInputs.length; i++){
if (colInputs[i].type == "text" || colInputs [i].type == "password") {
colInputs[i].onfocus = function () { this.select(); };
}
}
for (var i=0; i < colTextAreas.length; i++){
colTextAreas[i].onfocus = function () { this.select(); };
}
};
//自动切换到下一个
FormUtil.tabForward = function(oTextbox){
var oForm = oTextbox.form;
if(oForm.elements[oForm.elements.length-1]!=oTextbox && oTextbox.value.length==oTextbox.maxLength){
for (var i=0; i<oForm.elements.length; i++) {
if (oForm.elements[i] == oTextbox) {
for(var j=i+1; j < oForm.elements.length; j++) {
if (oForm.elements[j].type != "hidden") {
oForm.elements[j].focus();
return;
}
}
return;
}
}
}
};
window.onload = function(){
FormUtil.focusFirst();
FormUtil.setTextboxes();
};
//表单的提交
//<input type="image" src="sweat.gif">
//<input type="submit" src="Submit">
//oForm.submit();
//仅提交一次
//this.disabled = true;this.form.submit();
//选择文件select()
//<input type="text" name="" value="abc">
</script>
<body>
<form action="">
<input type="hidden" name="" value="">
信息:<input type="text" name="" value="abc" maxLength="10" onkeyup="javascript:FormUtil.tabForward(this);"><br/>
信息:<textarea rows="10" cols="30">abc</textarea>
<input type="image" src="sweat.gif">
</form>
</body>
</html>
Smilar Posts of javascript form
-
Process migration from tomcat to websphere changes
Process migration from tomcat to websphere changes Because customers use the web application server software used by different what tomcat5, tomcat6, websphere5.1, websphere6.1, weblogic8, and so on, ...
-
JAVA EE JSP_JNDI
dsfdsa http://lindows.javaeye.com/admin/blogs/213348 Tomcat 6 with the connection pool data source configuration http://www.blogjava.net/ec2008/archive/2008/07/19/216063.html project: test Driver path ...
-
Hibernate connection pool configuration
Hibernate connection pool configuration oracle.jdbc.driver.OracleDriver jdbc: oracle: thin: @ 10.203.14.132:1521: remotedb
-
hibernate generic generic DAO
hibernate generic generic DAO
-
Servlet brief introduction
Servlet brief introduction: Servlet is a small application server Are used to complete the B / S architecture, the client requests the response to treatment Platform independence, performance, able to ...
-
Spring2.0 + hibernate3.1 + log4j + mysql demo
applicationContext.xml Non-attachment jar package, necessary friends can send an email to todd.liangt @ gmail.com
-
Struts2 + hibernate + spring problem user log in
dao layer services layer action jsp user name: Password:
-
Hibernate secondary cache
Hibernate cache: 2-bit cache, also known as process-level cache or SessionFactory level cache, secondary cache can be shared by all of the session Cache configuration and the use of: Will echcache.xml ...
-
Hibernate's lazy strategy
hibernate Lazy strategy can be used in: tag, it can be true / false Tags can values true / false type of necessary tools to enhance can tag values true / false / extra can be single-ended cor ...







