`

javascript表格和表单

阅读更多
<html>
<head>
<title>财政报表</title>
<style>
<!--
-->
</style>
</head>
<body> 
<table summary="This table shows the yearly income for years 2005 through 2008" border="1">
    <caption>财政报表 2005 - 2008</caption>
	<tbody>
    <tr>
		<th></th>
		<th scope="col">2005</th>
		<th scope="col">2006</th>
		<th scope="col">2007</th>
		<th scope="col">2008</th>
	</tr>
	<tr>
		<th scope="row">拨款</th>
		<td>11,980</td>
		<td>12,650</td>
		<td>9,700</td>
		<td>10,600</td>
	</tr>
	<tr>
		<th scope="row">捐款</th>
		<td>4,780</td>
		<td>4,989</td>
		<td>6,700</td>
		<td>6,590</td>
	</tr>
	<tr>
		<th scope="row">投资</th>
		<td>8,000</td>
		<td>8,100</td>
		<td>8,760</td>
		<td>8,490</td>
	</tr>
	<tr>
		<th scope="row">募捐</th>
		<td>3,200</td>
		<td>3,120</td>
		<td>3,700</td>
		<td>4,210</td>
	</tr>
	<tr>
		<th scope="row">销售</th>
		<td>28,400</td>
		<td>27,100</td>
		<td>27,950</td>
		<td>29,050</td>
	</tr>
	<tr>
		<th scope="row">杂费</th>
		<td>2,100</td>
		<td>1,900</td>
		<td>1,300</td>
		<td>1,760</td>
	</tr>
	<tr>
		<th scope="row">总计</th>
		<td>58,460</td>
		<td>57,859</td>
		<td>58,110</td>
		<td>60,700</td>
	</tr>
    </tbody>
</table>
</body>
</html>


<html>
<head>
<title>财政报表</title>
<style>
<!--
body{
	background-color:#ebf5ff;	/* 页面背景色 */
	margin:0px; padding:4px;
	text-align:center;			/* 居中对齐(IE有效) */
}
.datalist{
	color:#0046a6;				/* 表格文字颜色 */
	background-color:#d2e8ff;	/* 表格背景色 */
	font-family:Arial;			/* 表格字体 */
}
.datalist caption{
	font-size:18px;				/* 标题文字大小 */
	font-weight:bold;			/* 标题文字粗体 */
}
.datalist th{
	color:#003e7e;				/* 行、列名称颜色 */
	background-color:#7bb3ff;	/* 行、列名称的背景色 */
}
-->
</style>
</head>
<body> 
<table summary="This table shows the yearly income for years 2005 through 2008" border="1" class="datalist">
	<caption>财政报表 2005 - 2008</caption>
    <tbody>
	<tr>
		<th></th>
		<th scope="col">2005</th>
		<th scope="col">2006</th>
		<th scope="col">2007</th>
		<th scope="col">2008</th>
	</tr>
	<tr>
		<th scope="row">拨款</th>
		<td>11,980</td>
		<td>12,650</td>
		<td>9,700</td>
		<td>10,600</td>
	</tr>
	<tr>
		<th scope="row">捐款</th>
		<td>4,780</td>
		<td>4,989</td>
		<td>6,700</td>
		<td>6,590</td>
	</tr>
	<tr>
		<th scope="row">投资</th>
		<td>8,000</td>
		<td>8,100</td>
		<td>8,760</td>
		<td>8,490</td>
	</tr>
	<tr>
		<th scope="row">募捐</th>
		<td>3,200</td>
		<td>3,120</td>
		<td>3,700</td>
		<td>4,210</td>
	</tr>
	<tr>
		<th scope="row">销售</th>
		<td>28,400</td>
		<td>27,100</td>
		<td>27,950</td>
		<td>29,050</td>
	</tr>
	<tr>
		<th scope="row">杂费</th>
		<td>2,100</td>
		<td>1,900</td>
		<td>1,300</td>
		<td>1,760</td>
	</tr>
	<tr>
		<th scope="row">总计</th>
		<td>58,460</td>
		<td>57,859</td>
		<td>58,110</td>
		<td>60,700</td>
	</tr>
    </tbody>
</table>
</body>
</html>


<html>
<head>
<title>财政报表</title>
<style>
<!--
.datalist{
	border:1px solid #429fff;	/* 表格边框 */
	font-family:Arial;
	border-collapse:collapse;	/* 边框重叠 */
}
.datalist caption{
	padding-top:3px;
	padding-bottom:2px;
	font:bold 1.1em;
	background-color:#f0f7ff;
	border:1px solid #429fff;	/* 表格标题边框 */
}
.datalist th{
	border:1px solid #429fff;	/* 行、列名称边框 */
	background-color:#d2e8ff;
	font-weight:bold;
	padding-top:4px; padding-bottom:4px;
	padding-left:10px; padding-right:10px;
	text-align:center;
}
.datalist td{
	border:1px solid #429fff;	/* 单元格边框 */
	text-align:right;
	padding:4px;
}
-->
</style>
</head>
<body> 
<table class="datalist">
	<caption>财政报表 2005 - 2008</caption>
	<tbody>
    <tr>
		<th></th>
		<th scope="col">2005</th>
		<th scope="col">2006</th>
		<th scope="col">2007</th>
		<th scope="col">2008</th>
	</tr>
	<tr>
		<th scope="row">拨款</th>
		<td>11,980</td>
		<td>12,650</td>
		<td>9,700</td>
		<td>10,600</td>
	</tr>
	<tr>
		<th scope="row">捐款</th>
		<td>4,780</td>
		<td>4,989</td>
		<td>6,700</td>
		<td>6,590</td>
	</tr>
	<tr>
		<th scope="row">投资</th>
		<td>8,000</td>
		<td>8,100</td>
		<td>8,760</td>
		<td>8,490</td>
	</tr>
	<tr>
		<th scope="row">募捐</th>
		<td>3,200</td>
		<td>3,120</td>
		<td>3,700</td>
		<td>4,210</td>
	</tr>
	<tr>
		<th scope="row">销售</th>
		<td>28,400</td>
		<td>27,100</td>
		<td>27,950</td>
		<td>29,050</td>
	</tr>
	<tr>
		<th scope="row">杂费</th>
		<td>2,100</td>
		<td>1,900</td>
		<td>1,300</td>
		<td>1,760</td>
	</tr>
	<tr>
		<th scope="row">总计</th>
		<td>58,460</td>
		<td>57,859</td>
		<td>58,110</td>
		<td>60,700</td>
	</tr>
    </tbody>
</table>
</body>
</html>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>动态添加</title>
<style>
<!--
.datalist{
	border:1px solid #0058a3;	/* 表格边框 */
	font-family:Arial;
	border-collapse:collapse;	/* 边框重叠 */
	background-color:#eaf5ff;	/* 表格背景色 */
	font-size:14px;
}
.datalist caption{
	padding-bottom:5px;
	font:bold 1.4em;
	text-align:left;
}
.datalist th{
	border:1px solid #0058a3;	/* 行名称边框 */
	background-color:#4bacff;	/* 行名称背景色 */
	color:#FFFFFF;				/* 行名称颜色 */
	font-weight:bold;
	padding-top:4px; padding-bottom:4px;
	padding-left:12px; padding-right:12px;
	text-align:center;
}
.datalist td{
	border:1px solid #0058a3;	/* 单元格边框 */
	text-align:left;
	padding-top:4px; padding-bottom:4px;
	padding-left:10px; padding-right:10px;
}
.datalist tr:hover, .datalist tr.altrow{
	background-color:#c4e4ff;	/* 动态变色 */
}
-->
</style>
<script language="javascript">
window.onload=function(){
	var oTr = document.getElementById("member").insertRow(2);	//插入一行
	var aText = new Array();
	aText[0] = document.createTextNode("fresheggs");
	aText[1] = document.createTextNode("W610");
	aText[2] = document.createTextNode("Nov 5th");
	aText[3] = document.createTextNode("Scorpio");
	aText[4] = document.createTextNode("1038818");
	for(var i=0;i<aText.length;i++){
		var oTd = oTr.insertCell(i);
		oTd.appendChild(aText[i]);
	}
}
</script>
</head>
<body>
<table class="datalist" summary="list of members in EE Studay" id="member">
	<caption>Member List</caption>
	<tr>
		<th scope="col">Name</th>
		<th scope="col">Class</th>
		<th scope="col">Birthday</th>
		<th scope="col">Constellation</th>
		<th scope="col">Mobile</th>
	</tr>
	<tr>
		<td>isaac</td>
		<td>W13</td>
		<td>Jun 24th</td>
		<td>Cancer</td>
		<td>1118159</td>
	</tr>
	<tr>
		<td>girlwing</td>
		<td>W210</td>
		<td>Sep 16th</td>
		<td>Virgo</td>
		<td>1307994</td>
	</tr>
	<tr>
		<td>tastestory</td>
		<td>W15</td>
		<td>Nov 29th</td>
		<td>Sagittarius</td>
		<td>1095245</td>
	</tr>
	<tr>
		<td>lovehate</td>
		<td>W47</td>
		<td>Sep 5th</td>
		<td>Virgo</td>
		<td>6098017</td>
	</tr>
	<tr>
		<td>slepox</td>
		<td>W19</td>
		<td>Nov 18th</td>
		<td>Scorpio</td>
		<td>0658635</td>
	</tr>
	<tr>
		<td>smartlau</td>
		<td>W19</td>
		<td>Dec 30th</td>
		<td>Capricorn</td>
		<td>0006621</td>
	</tr>
	<tr>
		<td>whaler</td>
		<td>W19</td>
		<td>Jan 18th</td>
		<td>Capricorn</td>
		<td>1851918</td>
	</tr>
	<tr>
		<td>shenhuanyan</td>
		<td>W25</td>
		<td>Jan 31th</td>
		<td>Aquarius</td>
		<td>0621827</td>
	</tr>
	<tr>
		<td>tuonene</td>
		<td>W210</td>
		<td>Nov 26th</td>
		<td>Sagittarius</td>
		<td>0091704</td>
	</tr>
	<tr>
		<td>ArthurRivers</td>
		<td>W91</td>
		<td>Feb 26th</td>
		<td>Pisces</td>
		<td>0468357</td>
	</tr>
	<tr>
		<td>reconzansp</td>
		<td>W09</td>
		<td>Oct 13th</td>
		<td>Libra</td>
		<td>3643041</td>
	</tr>
	<tr>
		<td>linear</td>
		<td>W86</td>
		<td>Aug 18th</td>
		<td>Leo</td>
		<td>6398341</td>
	</tr>
	<tr>
		<td>laopiao</td>
		<td>W41</td>
		<td>May 17th</td>
		<td>Taurus</td>
		<td>1254004</td>
	</tr>
	<tr>
		<td>dovecho</td>
		<td>W19</td>
		<td>Dec 9th</td>
		<td>Sagittarius</td>
		<td>1892013</td>
	</tr>
	<tr>
		<td>shanghen</td>
		<td>W42</td>
		<td>May 24th</td>
		<td>Gemini</td>
		<td>1544254</td>
	</tr>
	<tr>
		<td>venessawj</td>
		<td>W45</td>
		<td>Apr 1st</td>
		<td>Aries</td>
		<td>1523753</td>
	</tr>
	<tr>
		<td>lightyear</td>
		<td>W311</td>
		<td>Mar 23th</td>
		<td>Aries</td>
		<td>1002908</td>
	</tr>
</table>
</body>
</html>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>修改单元格内容</title>
<style>
<!--
.datalist{
	border:1px solid #0058a3;	/* 表格边框 */
	font-family:Arial;
	border-collapse:collapse;	/* 边框重叠 */
	background-color:#eaf5ff;	/* 表格背景色 */
	font-size:14px;
}
.datalist caption{
	padding-bottom:5px;
	font:bold 1.4em;
	text-align:left;
}
.datalist th{
	border:1px solid #0058a3;	/* 行名称边框 */
	background-color:#4bacff;	/* 行名称背景色 */
	color:#FFFFFF;				/* 行名称颜色 */
	font-weight:bold;
	padding-top:4px; padding-bottom:4px;
	padding-left:12px; padding-right:12px;
	text-align:center;
}
.datalist td{
	border:1px solid #0058a3;	/* 单元格边框 */
	text-align:left;
	padding-top:4px; padding-bottom:4px;
	padding-left:10px; padding-right:10px;
}
.datalist tr:hover, .datalist tr.altrow{
	background-color:#c4e4ff;	/* 动态变色 */
}
-->
</style>
<script language="javascript">
window.onload=function(){
	var oTable = document.getElementById("member");
	oTable.rows[3].cells[4].innerHTML = "lost";		//修改单元格内容
}
</script>
</head>
<body>
<table class="datalist" summary="list of members in EE Studay" id="member">
	<caption>Member List</caption>
	<tr>
		<th scope="col">Name</th>
		<th scope="col">Class</th>
		<th scope="col">Birthday</th>
		<th scope="col">Constellation</th>
		<th scope="col">Mobile</th>
	</tr>
	<tr>
		<td>isaac</td>
		<td>W13</td>
		<td>Jun 24th</td>
		<td>Cancer</td>
		<td>1118159</td>
	</tr>
	<tr>
		<td>girlwing</td>
		<td>W210</td>
		<td>Sep 16th</td>
		<td>Virgo</td>
		<td>1307994</td>
	</tr>
	<tr>
		<td>tastestory</td>
		<td>W15</td>
		<td>Nov 29th</td>
		<td>Sagittarius</td>
		<td>1095245</td>
	</tr>
	<tr>
		<td>lovehate</td>
		<td>W47</td>
		<td>Sep 5th</td>
		<td>Virgo</td>
		<td>6098017</td>
	</tr>
	<tr>
		<td>slepox</td>
		<td>W19</td>
		<td>Nov 18th</td>
		<td>Scorpio</td>
		<td>0658635</td>
	</tr>
	<tr>
		<td>smartlau</td>
		<td>W19</td>
		<td>Dec 30th</td>
		<td>Capricorn</td>
		<td>0006621</td>
	</tr>
	<tr>
		<td>whaler</td>
		<td>W19</td>
		<td>Jan 18th</td>
		<td>Capricorn</td>
		<td>1851918</td>
	</tr>
	<tr>
		<td>shenhuanyan</td>
		<td>W25</td>
		<td>Jan 31th</td>
		<td>Aquarius</td>
		<td>0621827</td>
	</tr>
	<tr>
		<td>tuonene</td>
		<td>W210</td>
		<td>Nov 26th</td>
		<td>Sagittarius</td>
		<td>0091704</td>
	</tr>
	<tr>
		<td>ArthurRivers</td>
		<td>W91</td>
		<td>Feb 26th</td>
		<td>Pisces</td>
		<td>0468357</td>
	</tr>
	<tr>
		<td>reconzansp</td>
		<td>W09</td>
		<td>Oct 13th</td>
		<td>Libra</td>
		<td>3643041</td>
	</tr>
	<tr>
		<td>linear</td>
		<td>W86</td>
		<td>Aug 18th</td>
		<td>Leo</td>
		<td>6398341</td>
	</tr>
	<tr>
		<td>laopiao</td>
		<td>W41</td>
		<td>May 17th</td>
		<td>Taurus</td>
		<td>1254004</td>
	</tr>
	<tr>
		<td>dovecho</td>
		<td>W19</td>
		<td>Dec 9th</td>
		<td>Sagittarius</td>
		<td>1892013</td>
	</tr>
	<tr>
		<td>shanghen</td>
		<td>W42</td>
		<td>May 24th</td>
		<td>Gemini</td>
		<td>1544254</td>
	</tr>
	<tr>
		<td>venessawj</td>
		<td>W45</td>
		<td>Apr 1st</td>
		<td>Aries</td>
		<td>1523753</td>
	</tr>
	<tr>
		<td>lightyear</td>
		<td>W311</td>
		<td>Mar 23th</td>
		<td>Aries</td>
		<td>1002908</td>
	</tr>
</table>
</body>
</html>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>动态删除</title>
<style>
<!--
.datalist{
	border:1px solid #0058a3;	/* 表格边框 */
	font-family:Arial;
	border-collapse:collapse;	/* 边框重叠 */
	background-color:#eaf5ff;	/* 表格背景色 */
	font-size:14px;
}
.datalist caption{
	padding-bottom:5px;
	font:bold 1.4em;
	text-align:left;
}
.datalist th{
	border:1px solid #0058a3;	/* 行名称边框 */
	background-color:#4bacff;	/* 行名称背景色 */
	color:#FFFFFF;				/* 行名称颜色 */
	font-weight:bold;
	padding-top:4px; padding-bottom:4px;
	padding-left:12px; padding-right:12px;
	text-align:center;
}
.datalist td{
	border:1px solid #0058a3;	/* 单元格边框 */
	text-align:left;
	padding-top:4px; padding-bottom:4px;
	padding-left:10px; padding-right:10px;
}
.datalist tr:hover, .datalist tr.altrow{
	background-color:#c4e4ff;	/* 动态变色 */
}
-->
</style>
<script language="javascript">
window.onload=function(){
	var oTable = document.getElementById("member");
	oTable.deleteRow(2);		//删除一行,后面的行号自动补齐
	oTable.rows[2].deleteCell(1);	//删除一个单元格,后面的也自动补齐
}
</script>
</head>
<body>
<table class="datalist" summary="list of members in EE Studay" id="member">
	<caption>Member List</caption>
	<tr>
		<th scope="col">Name</th>
		<th scope="col">Class</th>
		<th scope="col">Birthday</th>
		<th scope="col">Constellation</th>
		<th scope="col">Mobile</th>
	</tr>
	<tr>
		<td>isaac</td>
		<td>W13</td>
		<td>Jun 24th</td>
		<td>Cancer</td>
		<td>1118159</td>
	</tr>
	<tr>
		<td>girlwing</td>
		<td>W210</td>
		<td>Sep 16th</td>
		<td>Virgo</td>
		<td>1307994</td>
	</tr>
	<tr>
		<td>tastestory</td>
		<td>W15</td>
		<td>Nov 29th</td>
		<td>Sagittarius</td>
		<td>1095245</td>
	</tr>
	<tr>
		<td>lovehate</td>
		<td>W47</td>
		<td>Sep 5th</td>
		<td>Virgo</td>
		<td>6098017</td>
	</tr>
	<tr>
		<td>slepox</td>
		<td>W19</td>
		<td>Nov 18th</td>
		<td>Scorpio</td>
		<td>0658635</td>
	</tr>
	<tr>
		<td>smartlau</td>
		<td>W19</td>
		<td>Dec 30th</td>
		<td>Capricorn</td>
		<td>0006621</td>
	</tr>
	<tr>
		<td>whaler</td>
		<td>W19</td>
		<td>Jan 18th</td>
		<td>Capricorn</td>
		<td>1851918</td>
	</tr>
	<tr>
		<td>shenhuanyan</td>
		<td>W25</td>
		<td>Jan 31th</td>
		<td>Aquarius</td>
		<td>0621827</td>
	</tr>
	<tr>
		<td>tuonene</td>
		<td>W210</td>
		<td>Nov 26th</td>
		<td>Sagittarius</td>
		<td>0091704</td>
	</tr>
	<tr>
		<td>ArthurRivers</td>
		<td>W91</td>
		<td>Feb 26th</td>
		<td>Pisces</td>
		<td>0468357</td>
	</tr>
	<tr>
		<td>reconzansp</td>
		<td>W09</td>
		<td>Oct 13th</td>
		<td>Libra</td>
		<td>3643041</td>
	</tr>
	<tr>
		<td>linear</td>
		<td>W86</td>
		<td>Aug 18th</td>
		<td>Leo</td>
		<td>6398341</td>
	</tr>
	<tr>
		<td>laopiao</td>
		<td>W41</td>
		<td>May 17th</td>
		<td>Taurus</td>
		<td>1254004</td>
	</tr>
	<tr>
		<td>dovecho</td>
		<td>W19</td>
		<td>Dec 9th</td>
		<td>Sagittarius</td>
		<td>1892013</td>
	</tr>
	<tr>
		<td>shanghen</td>
		<td>W42</td>
		<td>May 24th</td>
		<td>Gemini</td>
		<td>1544254</td>
	</tr>
	<tr>
		<td>venessawj</td>
		<td>W45</td>
		<td>Apr 1st</td>
		<td>Aries</td>
		<td>1523753</td>
	</tr>
	<tr>
		<td>lightyear</td>
		<td>W311</td>
		<td>Mar 23th</td>
		<td>Aries</td>
		<td>1002908</td>
	</tr>
</table>
</body>
</html>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>动态删除</title>
<style>
<!--
.datalist{
	border:1px solid #0058a3;	/* 表格边框 */
	font-family:Arial;
	border-collapse:collapse;	/* 边框重叠 */
	background-color:#eaf5ff;	/* 表格背景色 */
	font-size:14px;
}
.datalist caption{
	padding-bottom:5px;
	font:bold 1.4em;
	text-align:left;
}
.datalist th{
	border:1px solid #0058a3;	/* 行名称边框 */
	background-color:#4bacff;	/* 行名称背景色 */
	color:#FFFFFF;				/* 行名称颜色 */
	font-weight:bold;
	padding-top:4px; padding-bottom:4px;
	padding-left:12px; padding-right:12px;
	text-align:center;
}
.datalist td{
	border:1px solid #0058a3;	/* 单元格边框 */
	text-align:left;
	padding-top:4px; padding-bottom:4px;
	padding-left:10px; padding-right:10px;
}
.datalist tr:hover, .datalist tr.altrow{
	background-color:#c4e4ff;	/* 动态变色 */
}

.datalist td a:link, .datalist td a:visited{
	color:#004365;
	text-decoration:underline;
}
.datalist td a:hover{
	color:#000000;
	text-decoration:none;
}
-->
</style>
<script language="javascript">
function myDelete(){
	var oTable = document.getElementById("member");
	//删除该行
	this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);
}
window.onload=function(){
	var oTable = document.getElementById("member");
	var oTd;
	//动态添加delete链接
	for(var i=1;i<oTable.rows.length;i++){
		oTd = oTable.rows[i].insertCell(5);
		oTd.innerHTML = "<a href='#'>delete</a>";
		oTd.firstChild.onclick = myDelete;	//添加删除事件
	}
}
</script>
</head>
<body>
<table class="datalist" summary="list of members in EE Studay" id="member">
	<caption>Member List</caption>
	<tr>
		<th scope="col">Name</th>
		<th scope="col">Class</th>
		<th scope="col">Birthday</th>
		<th scope="col">Constellation</th>
		<th scope="col">Mobile</th>
        <th scope="col">Delete</th>
	</tr>
	<tr>
		<td>isaac</td>
		<td>W13</td>
		<td>Jun 24th</td>
		<td>Cancer</td>
		<td>1118159</td>
	</tr>
	<tr>
		<td>girlwing</td>
		<td>W210</td>
		<td>Sep 16th</td>
		<td>Virgo</td>
		<td>1307994</td>
	</tr>
	<tr>
		<td>tastestory</td>
		<td>W15</td>
		<td>Nov 29th</td>
		<td>Sagittarius</td>
		<td>1095245</td>
	</tr>
	<tr>
		<td>lovehate</td>
		<td>W47</td>
		<td>Sep 5th</td>
		<td>Virgo</td>
		<td>6098017</td>
	</tr>
	<tr>
		<td>slepox</td>
		<td>W19</td>
		<td>Nov 18th</td>
		<td>Scorpio</td>
		<td>0658635</td>
	</tr>
	<tr>
		<td>smartlau</td>
		<td>W19</td>
		<td>Dec 30th</td>
		<td>Capricorn</td>
		<td>0006621</td>
	</tr>
	<tr>
		<td>whaler</td>
		<td>W19</td>
		<td>Jan 18th</td>
		<td>Capricorn</td>
		<td>1851918</td>
	</tr>
	<tr>
		<td>shenhuanyan</td>
		<td>W25</td>
		<td>Jan 31th</td>
		<td>Aquarius</td>
		<td>0621827</td>
	</tr>
	<tr>
		<td>tuonene</td>
		<td>W210</td>
		<td>Nov 26th</td>
		<td>Sagittarius</td>
		<td>0091704</td>
	</tr>
	<tr>
		<td>ArthurRivers</td>
		<td>W91</td>
		<td>Feb 26th</td>
		<td>Pisces</td>
		<td>0468357</td>
	</tr>
	<tr>
		<td>reconzansp</td>
		<td>W09</td>
		<td>Oct 13th</td>
		<td>Libra</td>
		<td>3643041</td>
	</tr>
	<tr>
		<td>linear</td>
		<td>W86</td>
		<td>Aug 18th</td>
		<td>Leo</td>
		<td>6398341</td>
	</tr>
	<tr>
		<td>laopiao</td>
		<td>W41</td>
		<td>May 17th</td>
		<td>Taurus</td>
		<td>1254004</td>
	</tr>
	<tr>
		<td>dovecho</td>
		<td>W19</td>
		<td>Dec 9th</td>
		<td>Sagittarius</td>
		<td>1892013</td>
	</tr>
	<tr>
		<td>shanghen</td>
		<td>W42</td>
		<td>May 24th</td>
		<td>Gemini</td>
		<td>1544254</td>
	</tr>
	<tr>
		<td>venessawj</td>
		<td>W45</td>
		<td>Apr 1st</td>
		<td>Aries</td>
		<td>1523753</td>
	</tr>
	<tr>
		<td>lightyear</td>
		<td>W311</td>
		<td>Mar 23th</td>
		<td>Aries</td>
		<td>1002908</td>
	</tr>
</table>
</body>
</html>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>动态删除列</title>
<style>
<!--
.datalist{
	border:1px solid #0058a3;	/* 表格边框 */
	font-family:Arial;
	border-collapse:collapse;	/* 边框重叠 */
	background-color:#eaf5ff;	/* 表格背景色 */
	font-size:14px;
}
.datalist caption{
	padding-bottom:5px;
	font:bold 1.4em;
	text-align:left;
}
.datalist th{
	border:1px solid #0058a3;	/* 行名称边框 */
	background-color:#4bacff;	/* 行名称背景色 */
	color:#FFFFFF;				/* 行名称颜色 */
	font-weight:bold;
	padding-top:4px; padding-bottom:4px;
	padding-left:12px; padding-right:12px;
	text-align:center;
}
.datalist td{
	border:1px solid #0058a3;	/* 单元格边框 */
	text-align:left;
	padding-top:4px; padding-bottom:4px;
	padding-left:10px; padding-right:10px;
}
.datalist tr:hover, .datalist tr.altrow{
	background-color:#c4e4ff;	/* 动态变色 */
}
-->
</style>
<script language="javascript">
function deleteColumn(oTable,iNum){
	//自定义删除列函数,即每行删除相应单元格
	for(var i=0;i<oTable.rows.length;i++)
		oTable.rows[i].deleteCell(iNum);
}
window.onload=function(){
	var oTable = document.getElementById("member");
	deleteColumn(oTable,2);
}
</script>
</head>
<body>
<table class="datalist" summary="list of members in EE Studay" id="member">
	<caption>Member List</caption>
	<tr>
		<th scope="col">Name</th>
		<th scope="col">Class</th>
		<th scope="col">Birthday</th>
		<th scope="col">Constellation</th>
		<th scope="col">Mobile</th>
	</tr>
	<tr>
		<td>isaac</td>
		<td>W13</td>
		<td>Jun 24th</td>
		<td>Cancer</td>
		<td>1118159</td>
	</tr>
	<tr>
		<td>girlwing</td>
		<td>W210</td>
		<td>Sep 16th</td>
		<td>Virgo</td>
		<td>1307994</td>
	</tr>
	<tr>
		<td>tastestory</td>
		<td>W15</td>
		<td>Nov 29th</td>
		<td>Sagittarius</td>
		<td>1095245</td>
	</tr>
	<tr>
		<td>lovehate</td>
		<td>W47</td>
		<td>Sep 5th</td>
		<td>Virgo</td>
		<td>6098017</td>
	</tr>
	<tr>
		<td>slepox</td>
		<td>W19</td>
		<td>Nov 18th</td>
		<td>Scorpio</td>
		<td>0658635</td>
	</tr>
	<tr>
		<td>smartlau</td>
		<td>W19</td>
		<td>Dec 30th</td>
		<td>Capricorn</td>
		<td>0006621</td>
	</tr>
	<tr>
		<td>whaler</td>
		<td>W19</td>
		<td>Jan 18th</td>
		<td>Capricorn</td>
		<td>1851918</td>
	</tr>
	<tr>
		<td>shenhuanyan</td>
		<td>W25</td>
		<td>Jan 31th</td>
		<td>Aquarius</td>
		<td>0621827</td>
	</tr>
	<tr>
		<td>tuonene</td>
		<td>W210</td>
		<td>Nov 26th</td>
		<td>Sagittarius</td>
		<td>0091704</td>
	</tr>
	<tr>
		<td>ArthurRivers</td>
		<td>W91</td>
		<td>Feb 26th</td>
		<td>Pisces</td>
		<td>0468357</td>
	</tr>
	<tr>
		<td>reconzansp</td>
		<td>W09</td>
		<td>Oct 13th</td>
		<td>Libra</td>
		<td>3643041</td>
	</tr>
	<tr>
		<td>linear</td>
		<td>W86</td>
		<td>Aug 18th</td>
		<td>Leo</td>
		<td>6398341</td>
	</tr>
	<tr>
		<td>laopiao</td>
		<td>W41</td>
		<td>May 17th</td>
		<td>Taurus</td>
		<td>1254004</td>
	</tr>
	<tr>
		<td>dovecho</td>
		<td>W19</td>
		<td>Dec 9th</td>
		<td>Sagittarius</td>
		<td>1892013</td>
	</tr>
	<tr>
		<td>shanghen</td>
		<td>W42</td>
		<td>May 24th</td>
		<td>Gemini</td>
		<td>1544254</td>
	</tr>
	<tr>
		<td>venessawj</td>
		<td>W45</td>
		<td>Apr 1st</td>
		<td>Aries</td>
		<td>1523753</td>
	</tr>
	<tr>
		<td>lightyear</td>
		<td>W311</td>
		<td>Mar 23th</td>
		<td>Aries</td>
		<td>1002908</td>
	</tr>
</table>
</body>
</html>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Form Example</title>
</head>
<body>
<form method="post" name="myForm1" action="addInfo.aspx">
<p><label for="name">请输入您的姓名:</label><br><input type="text" name="name" id="name"></p>
<p><label for="passwd">请输入您的密码:</label><br><input type="password" name="passwd" id="passwd"></p>
<p><label for="color">请选择你最喜欢的颜色:</label><br>
<select name="color" id="color">
	<option value="red">红</option>
	<option value="green">绿</option>
	<option value="blue">蓝</option>
	<option value="yellow">黄</option>
	<option value="cyan">青</option>
	<option value="purple">紫</option>
</select></p>
<p>请选择你的性别:<br>
	<input type="radio" name="sex" id="male" value="male"><label for="male">男</label><br>
	<input type="radio" name="sex" id="female" value="female"><label for="female">女</label></p>
<p>你喜欢做些什么:<br>
	<input type="checkbox" name="hobby" id="book" value="book"><label for="book">看书</label>
	<input type="checkbox" name="hobby" id="net" value="net"><label for="net">上网</label>
	<input type="checkbox" name="hobby" id="sleep" value="sleep"><label for="sleep">睡觉</label></p>
<p><label for="comments">我要留言:</label><br><textarea name="comments" id="comments" cols="30" rows="4"></textarea></p>
<p><input type="submit" name="btnSubmit" id="btnSubmit" value="Submit">
<input type="reset" name="btnReset" id="btnReset" value="Reset"></p>
</form>
</body>
</html>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Form Example</title>
<style>
<!--
/* 直接控制各个标记 */
form {
	border: 1px dotted #AAAAAA;
	padding: 3px 6px 3px 6px;
	margin:0px;
	font:14px Arial;
}
input {
	color: #00008B;
	background-color: #ADD8E6;
	border: 1px solid #00008B;
}
select {
	width: 80px;
	color: #00008B;
	background-color: #ADD8E6;
	border: 1px solid #00008B;
}
textarea {
	width: 200px;
	height: 40px;
	color: #00008B;
	background-color: #ADD8E6;
	border: 1px solid #00008B;
}
-->
</style>
</head>
<body>
<form method="post" name="myForm1" action="addInfo.aspx">
<p><label for="name">请输入您的姓名:</label><br><input type="text" name="name" id="name"></p>
<p><label for="passwd">请输入您的密码:</label><br><input type="password" name="passwd" id="passwd"></p>
<p><label for="color">请选择你最喜欢的颜色:</label><br>
<select name="color" id="color">
	<option value="red">红</option>
	<option value="green">绿</option>
	<option value="blue">蓝</option>
	<option value="yellow">黄</option>
	<option value="cyan">青</option>
	<option value="purple">紫</option>
</select></p>
<p>请选择你的性别:<br>
	<input type="radio" name="sex" id="male" value="male"><label for="male">男</label><br>
	<input type="radio" name="sex" id="female" value="female"><label for="female">女</label></p>
<p>你喜欢做些什么:<br>
	<input type="checkbox" name="hobby" id="book" value="book"><label for="book">看书</label>
	<input type="checkbox" name="hobby" id="net" value="net"><label for="net">上网</label>
	<input type="checkbox" name="hobby" id="sleep" value="sleep"><label for="sleep">睡觉</label></p>
<p><label for="comments">我要留言:</label><br><textarea name="comments" id="comments" cols="30" rows="4"></textarea></p>
<p><input type="submit" name="btnSubmit" id="btnSubmit" value="Submit">
<input type="reset" name="btnReset" id="btnReset" value="Reset"></p>
</form>
</body>
</html>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Form Example</title>
<style>
<!--
form{
	border: 1px dotted #AAAAAA;
	padding: 1px 6px 1px 6px;
	margin:0px;
	font:14px Arial;
}
input{							/* 所有input标记 */
	color: #00008B;	
}
input.txt{						/* 文本框单独设置 */
	border: 1px inset #00008B;
	background-color: #ADD8E6;
}
input.btn{						/* 按钮单独设置 */
	color: #00008B;
	background-color: #ADD8E6;
	border: 1px outset #00008B;
	padding: 1px 2px 1px 2px;
}
select{
	width: 80px;
	color: #00008B;
	background-color: #ADD8E6;
	border: 1px solid #00008B;
}
textarea{
	width: 200px;
	height: 40px;
	color: #00008B;
	background-color: #ADD8E6;
	border: 1px inset #00008B;
}
-->
</style>
</head>
<body>
<form method="post" name="myForm1" action="addInfo.aspx">
<p><label for="name">请输入您的姓名:</label><br><input type="text" name="name" id="name" class="txt"></p>
<p><label for="passwd">请输入您的密码:</label><br><input type="password" name="passwd" id="passwd" class="txt"></p>
<p><label for="color">请选择你最喜欢的颜色:</label><br>
<select name="color" id="color">
	<option value="red">红</option>
	<option value="green">绿</option>
	<option value="blue">蓝</option>
	<option value="yellow">黄</option>
	<option value="cyan">青</option>
	<option value="purple">紫</option>
</select></p>
<p>请选择你的性别:<br>
	<input type="radio" name="sex" id="male" value="male"><label for="male">男</label><br>
	<input type="radio" name="sex" id="female" value="female"><label for="female">女</label></p>
<p>你喜欢做些什么:<br>
	<input type="checkbox" name="hobby" id="book" value="book"><label for="book">看书</label>
	<input type="checkbox" name="hobby" id="net" value="net"><label for="net">上网</label>
	<input type="checkbox" name="hobby" id="sleep" value="sleep"><label for="sleep">睡觉</label></p>
<p><label for="comments">我要留言:</label><br><textarea name="comments" id="comments" cols="30" rows="4"></textarea></p>
<p><input type="submit" name="btnSubmit" id="btnSubmit" value="Submit" class="btn">
<input type="reset" name="btnReset" id="btnReset" value="Reset" class="btn"></p>
</form>
</body>
</html>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>控制textarea的字符个数</title>
<style>
<!--
form{
	padding:0px;
	margin:0px;
	font:14px Arial;
}
input.txt{						/* 文本框单独设置 */
	border: 1px inset #00008B;
	background-color: #ADD8E6;
}
input.btn{						/* 按钮单独设置 */
	color: #00008B;
	background-color: #ADD8E6;
	border: 1px outset #00008B;
	padding: 1px 2px 1px 2px;
}
-->
</style>
<script language="javascript">
function LessThan(oTextArea){
	//返回文本框字符个数是否符号要求的boolean值
	return oTextArea.value.length < oTextArea.getAttribute("maxlength");
}
</script>
</head>
<body>
<form method="post" name="myForm1" action="addInfo.aspx">
<p><label for="name">请输入您的姓名:</label>
<input type="text" name="name" id="name" class="txt" value="姓名" maxlength="10"></p>
<p><label for="comments">我要留言:</label><br>
<textarea name="comments" id="comments" cols="40" rows="4" maxlength="50" onkeypress="return LessThan(this);"></textarea></p>
<p><input type="submit" name="btnSubmit" id="btnSubmit" value="Submit" class="btn">
<input type="reset" name="btnReset" id="btnReset" value="Reset" class="btn"></p>
</form>
</body>
</html>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Automatic Selecting</title>
<style>
<!--
form{
	padding:0px; margin:0px;
	font:14px Arial;
}
input.txt{
	border: 1px inset #00008B;
	background-color: #ADD8E6;
}
input.btn{
	color: #00008B;
	background-color: #ADD8E6;
	border: 1px outset #00008B;
	padding: 1px 2px 1px 2px;
}
-->
</style>
</head>
<body>
<form method="post" name="myForm1" action="addInfo.aspx">
<p><label for="name">请输入您的姓名:</label>
<input type="text" name="name" id="name" class="txt" value="姓名" onmouseover="this.focus()" onfocus="this.select()"></p>
<p><label for="passwd">请输入您的密码:</label>
<input type="password" name="passwd" id="passwd" class="txt"></p>
<p><input type="submit" name="btnSubmit" id="btnSubmit" value="Submit" class="btn">
<input type="reset" name="btnReset" id="btnReset" value="Reset" class="btn"></p>
</form>
</body>
</html>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Automatic Selecting</title>
<style>
<!--
form{
	padding:0px;
	margin:0px;
	font:14px Arial;
}
input.txt{						/* 文本框单独设置 */
	border: 1px inset #00008B;
	background-color: #ADD8E6;
}
input.btn{						/* 按钮单独设置 */
	color: #00008B;
	background-color: #ADD8E6;
	border: 1px outset #00008B;
	padding: 1px 2px 1px 2px;
}
-->
</style>
<script language="javascript">
function myFocus(){
	this.focus();
}
function mySelect(){
	this.select();
}
window.onload = function(){
	var oForm = document.forms["myForm1"];
	oForm.name.onmouseover = myFocus;
	oForm.name.onfocus = mySelect;
}
</script>
</head>
<body>
<form method="post" name="myForm1" action="addInfo.aspx">
<p><label for="name">请输入您的姓名:</label>
<input type="text" name="name" id="name" class="txt" value="姓名"></p>
<p><label for="passwd">请输入您的密码:</label>
<input type="password" name="passwd" id="passwd" class="txt"></p>
<p><input type="submit" name="btnSubmit" id="btnSubmit" value="Submit" class="btn">
<input type="reset" name="btnReset" id="btnReset" value="Reset" class="btn"></p>
</form>
</body>
</html>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>单选项</title>
<style>
<!--
form{
	padding:0px; margin:0px;
	font:14px Arial;
}
p{
	padding:2px; margin:0px;
}
-->
</style>
<script language="javascript">
function getChoice(){
	var oForm = document.forms["myForm1"];
	var aChoices = oForm.camera;
	for(i=0;i<aChoices.length;i++)	//遍历整个单选项表
		if(aChoices[i].checked)	//如果发现了被选中项则退出
			break;
	alert("您使用的相机品牌是:"+aChoices[i].value);
}
function setChoice(iNum){
	var oForm = document.forms["myForm1"];
	oForm.camera[iNum].checked = true;
}
</script>
</head>
<body>
<form method="post" name="myForm1" action="addInfo.aspx">
您使用的相机品牌:
<p>
	<input type="radio" name="camera" id="canon" value="Canon">
	<label for="canon">Canon</label>
</p>
<p>
	<input type="radio" name="camera" id="nikon" value="Nikon">
	<label for="nikon">Nikon</label>
</p>
<p>
	<input type="radio" name="camera" id="sony" value="Sony" checked>
	<label for="sony">Sony</label>
</p>
<p>
	<input type="radio" name="camera" id="olympus" value="Olympus">
	<label for="olympus">Olympus</label>
</p>
<p>
	<input type="radio" name="camera" id="samsung" value="Samsung">
	<label for="samsung">Samsung</label>
</p>
<p>
	<input type="radio" name="camera" id="pentax" value="Pentax">
	<label for="pentax">Pentax</label>
</p>
<p>
	<input type="radio" name="camera" id="others" value="其它">
	<label for="others">others</label>
</p>
<p><input type="submit" name="btnSubmit" id="btnSubmit" value="Submit" class="btn"></p>
<p><input type="button" value="检测选中对象" onclick="getChoice();">
<input type="button" value="设置为Canon" onclick="setChoice(0);"></p>
</form>
</body>
</html>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>多选项</title>
<style>
<!--
form{
	padding:0px; margin:0px;
	font:14px Arial;
}
p{
	padding:2px; margin:0px;
}
-->
</style>
<script language="javascript">
function changeBoxes(action){
	var oForm = document.forms["myForm1"];
	var oCheckBox = oForm.hobby;
	for(var i=0;i<oCheckBox.length;i++)		//遍历每一个选项
		if(action<0)							//反选
			oCheckBox[i].checked = !oCheckBox[i].checked;
		else			//action为1是则全选,为0时则全不选
			oCheckBox[i].checked = action;
}
</script>
</head>
<body>
<form method="post" name="myForm1" action="addInfo.aspx">
您喜欢做的事情:
<p>
	<input type="checkbox" name="hobby" id="ball" value="ball">
	<label for="ball">打球</label>
</p>
<p>
	<input type="checkbox" name="hobby" id="TV" value="TV">
	<label for="TV">看电视</label>
</p>
<p>
	<input type="checkbox" name="hobby" id="net" value="net">
	<label for="net">上网</label>
</p>
<p>
	<input type="checkbox" name="hobby" id="book" value="book">
	<label for="book">看书</label>
</p>
<p>
	<input type="checkbox" name="hobby" id="trip" value="trip">
	<label for="trip">旅游</label>
</p>
<p>
	<input type="checkbox" name="hobby" id="music" value="music">
	<label for="music">听音乐</label>
</p>
<p>
	<input type="checkbox" name="hobby" id="others" value="其它">
	<label for="others">其它</label>
</p>
<p>
<input type="button" value="全选" onclick="changeBoxes(1);" />
<input type="button" value="全不选" onclick="changeBoxes(0);" />
<input type="button" value="反选" onclick="changeBoxes(-1);" />
</p>
</form>
</body>
</html>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>下拉菜单,单选</title>
<style>
<!--
form{
	padding:0px; margin:0px;
	font:14px Arial;
}
-->
</style>
<script language="javascript">
function checkSingle(){
	var oForm = document.forms["myForm1"];
	var oSelectBox = oForm.constellation;
	var iChoice = oSelectBox.selectedIndex;	//获取选中项
	alert("您选中了" + oSelectBox.options[iChoice].text);
}
</script>
</head>
<body>
<form method="post" name="myForm1">
<label for="constellation">星座:</label>
<p>
<select id="constellation" name="constellation">
	<option value="Aries" selected="selected">白羊</option>
	<option value="Taurus">金牛</option>
	<option value="Gemini">双子</option>
	<option value="Cancer">巨蟹</option>
	<option value="Leo">狮子</option>
	<option value="Virgo">处女</option>
	<option value="Libra">天秤</option>
	<option value="Scorpio">天蝎</option>
	<option value="Sagittarius">射手</option>
	<option value="Capricorn">摩羯</option>
	<option value="Aquarius">水瓶</option>
	<option value="Pisces">双鱼</option>
</select>
</p>
<input type="button" onclick="checkSingle()" value="查看选项" />
</form>
</body>
</html>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>下拉菜单,多选</title>
<style>
<!--
form{
	padding:0px; margin:0px;
	font:14px Arial;
}
p{
	margin:0px; padding:2px;
}
-->
</style>
<script language="javascript">
function checkMultiple(){
	var oForm = document.forms["myForm1"];
	var oSelectBox = oForm.constellation;
	var aChoices = new Array();
	//遍历整个下拉菜单
	for(var i=0;i<oSelectBox.options.length;i++)
		if(oSelectBox.options[i].selected)	//如果被选中
			aChoices.push(oSelectBox.options[i].text);	//压入到数组中
	alert("您选了:" + aChoices.join());	//输出结果
}
</script>
</head>
<body>
<form method="post" name="myForm1">
<label for="constellation">星座:</label>
<p>
<select id="constellation" name="constellation" multiple="multiple" style="height:180px;">
	<option value="Aries">白羊</option>
	<option value="Taurus">金牛</option>
	<option value="Gemini">双子</option>
	<option value="Cancer">巨蟹</option>
	<option value="Leo">狮子</option>
	<option value="Virgo">处女</option>
	<option value="Libra">天秤</option>
	<option value="Scorpio">天蝎</option>
	<option value="Sagittarius">射手</option>
	<option value="Capricorn">摩羯</option>
	<option value="Aquarius">水瓶</option>
	<option value="Pisces">双鱼</option>
</select>
</p>
<input type="button" onclick="checkMultiple()" value="查看选项" />
</form>
</body>
</html>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>下拉菜单,通用</title>
<style>
<!--
form{
	padding:0px; margin:0px;
	font:14px Arial;
}
p{
	margin:0px; padding:3px;
}
input{
	margin:0px;
	border:1px solid #000000;
}
-->
</style>
<script language="javascript">
function getSelectValue(Box){
	var oForm = document.forms["myForm1"];
	var oSelectBox = oForm.elements[Box];	//根据参数相应的选择下拉菜单
	if(oSelectBox.type == "select-one"){	//判断是单选还是多选
		var iChoice = oSelectBox.selectedIndex;	//获取选中项
		alert("单选,您选中了" + oSelectBox.options[iChoice].text);
	}else{
		var aChoices = new Array();
		//遍历整个下拉菜单
		for(var i=0;i<oSelectBox.options.length;i++)
			if(oSelectBox.options[i].selected)	//如果被选中
				aChoices.push(oSelectBox.options[i].text);	//压入到数组中
		alert("多选,您选了:" + aChoices.join());	//输出结果
	}
}
</script>
</head>
<body>
<form method="post" name="myForm1">
星座:
<p>
<select id="constellation1" name="constellation1">
	<option value="Aries" selected="selected">白羊</option>
	<option value="Taurus">金牛</option>
	<option value="Gemini">双子</option>
	<option value="Cancer">巨蟹</option>
	<option value="Leo">狮子</option>
	<option value="Virgo">处女</option>
	<option value="Libra">天秤</option>
	<option value="Scorpio">天蝎</option>
	<option value="Sagittarius">射手</option>
	<option value="Capricorn">摩羯</option>
	<option value="Aquarius">水瓶</option>
	<option value="Pisces">双鱼</option>
</select>
<input type="button" onclick="getSelectValue('constellation1')" value="查看选项" />
</p>
<p>
<select id="constellation2" name="constellation2" multiple="multiple" style="height:120px;">
	<option value="Aries">白羊</option>
	<option value="Taurus">金牛</option>
	<option value="Gemini">双子</option>
	<option value="Cancer">巨蟹</option>
	<option value="Leo">狮子</option>
	<option value="Virgo">处女</option>
	<option value="Libra">天秤</option>
	<option value="Scorpio">天蝎</option>
	<option value="Sagittarius">射手</option>
	<option value="Capricorn">摩羯</option>
	<option value="Aquarius">水瓶</option>
	<option value="Pisces">双鱼</option>
</select>
<input type="button" onclick="getSelectValue('constellation2')" value="查看选项" />
</p>
</form>
</body>
</html>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>添加选项</title>
<style>
<!--
form{padding:0px; margin:0px; font:14px Arial;}
p{margin:0px; padding:3px;}
input{margin:0px; border:1px solid #000000;}
-->
</style>
<script language="javascript">
function AddOption(Box){	//添加选项
	var oForm = document.forms["myForm1"];
	var oBox = oForm.elements[Box];
	var oOption = new Option("乒乓球","Pingpang");
	oBox.options[oBox.options.length] = oOption;
}
</script>
</head>
<body>
<form method="post" name="myForm1">
球类:
<p>
<select id="ball" name="ball" multiple="multiple">
	<option value="Football">足球</option>
	<option value="Basketball">篮球</option>
	<option value="Volleyball">排球</option>
</select>
</p>
<input type="button" value="添加乒乓球" onclick="AddOption('ball');" />
</form>
</body>
</html>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>替换选项</title>
<style>
<!--
form{padding:0px; margin:0px; font:14px Arial;}
p{margin:0px; padding:3px;}
input{margin:0px; border:1px solid #000000;}
-->
</style>
<script language="javascript">
function ReplaceOption(Box,iNum){	//替换选项
	var oForm = document.forms["myForm1"];
	var oBox = oForm.elements[Box];
	var oOption = new Option("乒乓球","Pingpang");
	oBox.options[iNum] = oOption;	//替换第iNum个选项
}
</script>
</head>
<body>
<form method="post" name="myForm1">
球类:
<p>
<select id="ball" name="ball" multiple="multiple">
	<option value="Football">足球</option>
	<option value="Basketball">篮球</option>
	<option value="Volleyball">排球</option>
</select>
</p>
<input type="button" value="篮球替换为乒乓球" onclick="ReplaceOption('ball',1);" />
</form>
</body>
</html>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>添加到具体位置</title>
<style>
<!--
form{padding:0px; margin:0px; font:14px Arial;}
p{margin:0px; padding:3px;}
input{margin:0px; border:1px solid #000000;}
-->
</style>
<script language="javascript">
function AddOption(Box,iNum){
	var oForm = document.forms["myForm1"];
	var oBox = oForm.elements[Box];
	var oOption = new Option("乒乓球","Pingpang");
	oBox.insertBefore(oOption,oBox.options[iNum]);
}
</script>
</head>
<body>
<form method="post" name="myForm1">
球类:
<p>
<select id="ball" name="ball" multiple="multiple">
	<option value="Football">足球</option>
	<option value="Basketball">篮球</option>
	<option value="Volleyball">排球</option>
</select>
</p>
<input type="button" value="添加乒乓球" onclick="AddOption('ball',1);" />
</form>
</body>
</html>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>添加到具体位置</title>
<style>
<!--
form{padding:0px; margin:0px; font:14px Arial;}
p{margin:0px; padding:3px;}
input{margin:0px; border:1px solid #000000;}
-->
</style>
<script language="javascript">
function AddOption(Box,iNum){
	var oForm = document.forms["myForm1"];
	var oBox = oForm.elements[Box];
	var oOption = new Option("乒乓球","Pingpang");
	//兼容IE7,先添加选项到最后,再移动
	oBox.options[oBox.options.length] = oOption;
	oBox.insertBefore(oOption,oBox.options[iNum]);
}
</script>
</head>
<body>
<form method="post" name="myForm1">
球类:
<p>
<select id="ball" name="ball" multiple="multiple">
	<option value="Football">足球</option>
	<option value="Basketball">篮球</option>
	<option value="Volleyball">排球</option>
</select>
</p>
<input type="button" value="添加乒乓球" onclick="AddOption('ball',1);" />
</form>
</body>
</html>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>删除选项</title>
<style>
<!--
form{padding:0px; margin:0px; font:14px Arial;}
p{margin:0px; padding:3px;}
input{margin:0px; border:1px solid #000000;}
-->
</style>
<script language="javascript">
function RemoveOption(Box,iNum){
	var oForm = document.forms["myForm1"];
	var oBox = oForm.elements[Box];
	oBox.options[iNum] = null;	//删除选项
}
</script>
</head>
<body>
<form method="post" name="myForm1">
球类:
<p>
<select id="ball" name="ball" multiple="multiple">
	<option value="Football">足球</option>
	<option value="Basketball">篮球</option>
	<option value="Volleyball">排球</option>
</select>
</p>
<input type="button" value="删除篮球" onclick="RemoveOption('ball',1);" />
</form>
</body>
</html>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>自动提示的文本框</title>
<style>
<!--
body{
	font-family:Arial, Helvetica, sans-serif;
	font-size:12px; padding:0px; margin:5px;
}
form{padding:0px; margin:0px;}
input{
	/* 用户输入框的样式 */
	font-family:Arial, Helvetica, sans-serif;
	font-size:12px; border:1px solid #000000;
	width:200px; padding:1px; margin:0px;
}
#popup{
	/* 提示框div块的样式 */
	position:absolute; width:202px;
	color:#004a7e; font-size:12px;
	font-family:Arial, Helvetica, sans-serif;
	left:41px; top:25px;
}
#popup.show{
	/* 显示提示框的边框 */	
	border:1px solid #004a7e;
}
#popup.hide{
	/* 隐藏提示框的边框 */
	border:none;
}
/* 提示框的样式风格 */
ul{
	list-style:none;
	margin:0px; padding:0px;
}
li.mouseOver{
	background-color:#004a7e;
	color:#FFFFFF;
}
li.mouseOut{
	background-color:#FFFFFF;
	color:#004a7e;
}
-->
</style>
<script language="javascript">
var oInputField;	//考虑到很多函数中都要使用
var oPopDiv;		//因此采用全局变量的形式
var oColorsUl;
var aColors = ["red","green","blue","magenta","yellow","chocolate","black","aquamarine","lime","fuchsia","brass","azure","brown","bronze","deeppink","aliceblue","gray","copper","coral","feldspar","orange","orchid","pink","plum","quartz","purple","antiquewith","blanchedalmond","blueviolet","beige","burlywood","bisque","cadetblue","saddlebrown","royalblue","rosybrown","orengered","olivedrab","powderblue","peachpuff","papayawhip","paleturquoise","palevioletred","palegreen","navyblue","navajowhite","palegodenrod","violetred","yellowgreen","tomato","turquoise","thistle","springgreen","steelblue","salmon","scarlet","silver","violet","snow","tan","chartreuse","khaki","mediumslateblue","mediumvioletred","oldlace","maroom","goldenrod","wheat","whitesmoke","moccasin","mistyrose","mintcream","midnightblue","dimgray","darksalmon","slategray","skyblue","sienna","seashell","seagreen","sandybrown","gold","mediumturquoise","navy","mediumspringgreen","mediumseagreen","mediumpurpul","peru","mediumorchid","mediumblue","mediumaquamarine","maroon","limegreen","lightyellow","lightsteelblue","magenta","lightslateblue","lightslategray","lightskyblue","inen","lightseagreen","lightsalmon","lightpink","lightgray","lightgreen","lightgodenrodyellow","indianred","lavender","lightblue","lavenderblush","lightcoral","lightcyan","lightgodenrod","hotpink","greenyellow","lemonchiffon","lawngreen","deepskyblue","honeydew","golenrod","forestgreen","gostwhite","gainsboro","firebrick","dodgerblue","darkturquoise","darkslateblue","darkslategray","darkseagreen","darkred","darkorchid","darkorenge","darkviolet","floralwhite","cyan","darkgray","cornsilk","darkolivegreen","darkgoldenrod","darkblue","darkcyan","darkgreen","darkhaki","ivory","darkmagenta","cornfloewrblue"];
aColors.sort();	//按字母排序,使显示结果更友好
function initVars(){
	//初始化变量
	oInputField = document.forms["myForm1"].colors;
	oPopDiv = document.getElementById("popup");
	oColorsUl = document.getElementById("colors_ul");
}
function clearColors(){
	//清除提示内容
	for(var i=oColorsUl.childNodes.length-1;i>=0;i--)
		oColorsUl.removeChild(oColorsUl.childNodes[i]);
	oPopDiv.className = "hide";
}
function setColors(the_colors){
	//显示提示框,传入的参数即为匹配出来的结果组成的数组
	clearColors();	//每输入一个字母就先清除原先的提示,再继续
	oPopDiv.className = "show";
	var oLi;
	for(var i=0;i<the_colors.length;i++){
		//将匹配的提示结果逐一显示给用户
		oLi = document.createElement("li");
		oColorsUl.appendChild(oLi);
		oLi.appendChild(document.createTextNode(the_colors[i]));

		oLi.onmouseover = function(){
			this.className = "mouseOver";	//鼠标经过时高亮
		}
		oLi.onmouseout = function(){
			this.className = "mouseOut";	//离开时恢复原样
		}
		oLi.onclick = function(){
			//用户点击某个匹配项时,设置输入框为该项的值
			oInputField.value = this.firstChild.nodeValue;
			clearColors();	//同时清除提示框
		}
	}
}
function findColors(){
	initVars();		//初始化变量
	if(oInputField.value.length > 0){
		var aResult = new Array();		//用于存放匹配结果
		for(var i=0;i<aColors.length;i++)	//从颜色表中找匹配的颜色
			//必须是从单词的开始处匹配
			if(aColors[i].indexOf(oInputField.value) == 0)
				aResult.push(aColors[i]);	//压入结果
		if(aResult.length>0)	//如果有匹配的颜色则显示出来
			setColors(aResult);
		else					//否则清除,用户多输入一个字母
			clearColors();		//就有可能从有匹配到无,到无的时候需要清除
	}		
	else
		clearColors();	//无输入时清除提示框(例如用户按del键)
}
</script>
</head>
<body>
<form method="post" name="myForm1">
Color: <input type="text" name="colors" id="colors" onkeyup="findColors();" />
</form>
<div id="popup">
	<ul id="colors_ul"></ul>
</div>
</body>
</html>
分享到:
评论

相关推荐

    按钮 表格 表单验证

    在网页设计和开发中,按钮、表格和表单验证是三个关键元素,它们共同构建了用户与网站交互的基础。下面将详细阐述这三个方面的知识。 首先,我们来看“按钮”。按钮在网页中扮演着触发动作的角色,它允许用户执行...

    javascript二级联动表单

    javascript二级联动表单javascript二级联动表单javascript二级联动表单javascript二级联动表单javascript二级联动表单javascript二级联动表单javascript二级联动表单javascript二级联动表单

    javascript 表格操作

    在探讨“javascript表格操作”这一主题时,我们深入解析如何使用JavaScript来动态地创建、修改和操作HTML表格。以下是从给定的代码片段中提取的关键知识点: ### 动态插入行与删除行 #### 插入行:`insertRow()` -...

    JavaScript 趣味案例-事件处理-dom操作表格 示例代码

    包含表格表单创建、样式设置、事件绑定(表格、表单、复选框)、事件处理JavaScript 事件处理 示例代码 包含表格表单创建、样式设置、事件绑定(表格、表单、复选框)、事件处理JavaScript 事件处理 示例代码 包含...

    javascript动态添加表格数据行

    首先,我们需要创建一个基本的HTML结构,包括一个表单和一个表格。表格中包含预定义的列,如项目名称、项目描述、开始日期和完成日期。此外,还有一行隐藏的模板行,用于动态添加新记录。表单中还有一个“Add”按钮...

    vue3+ts 表单和表格配置化组件

    "vue3+ts 表单和表格配置化组件"这一主题,主要关注的是如何利用Vue3、TypeScript以及Element Plus来创建高度可配置的表单和表格组件。这些组件通常用于处理动态数据,允许开发者通过配置对象来定义表单字段或表格列...

    JavaScript程序设计——页面设置与表单验证实验报告.docx

    实验报告的标题“JavaScript程序设计——页面设置与表单验证实验报告.docx”涉及的核心是JavaScript编程中的两个关键领域:页面设置和表单验证。在Web开发中,JavaScript是一种常用的客户端脚本语言,用于增强用户的...

    可编辑表格(表单)简易实现

    总结,实现一个可编辑表格(表单)需要结合HTML、CSS、JavaScript以及可能的前端框架,与后端配合完成数据的提交和处理。通过这样的方式,我们可以创建出一个功能完备、用户体验良好的网页表单系统。

    表格、表单提示显示-HTML-代码

    总之,"表格、表单提示显示-HTML-代码"这个资源将帮助开发者深入理解如何利用HTML、CSS和JavaScript构建具有交互性与动态效果的网页。通过学习和实践这个示例,你可以提升在前端开发中的技能,尤其是关于表格和表单...

    纯javascript增加删除表格行

    在本主题中,我们将深入探讨如何使用纯JavaScript来实现表格(table)的行增删功能,这对于创建数据管理界面或者用户输入表单的网页特别有用。 首先,我们需要了解HTML中的`&lt;table&gt;`元素。`&lt;table&gt;`是用于展示结构...

    基于elementui的form表单实现的一个高拓展性的表格布局组件

    首先,Element UI的Form组件提供了强大的表单处理能力,它支持各种表单元素如Input、Select、Checkbox、Radio等,并且具有表单验证功能,能够方便地实现动态表单和自定义验证规则。要创建一个高拓展性的表格布局组件...

    layui form表单提交之后重新加载数据表格的方法

    通过上述的分析,我们可以看到,layui框架在处理表单提交和数据表格刷新方面提供了强大的工具。开发者可以利用这些工具高效地构建出动态的用户界面。需要注意的是,由于本文的某些部分是OCR扫描识别的结果,可能包含...

    JavaScript的各种页面,表格,窗口,按钮,链接等特效

    本教程将探讨JavaScript在实现页面、表格、窗口、按钮和链接等元素的各种特效方面的应用。 1. 页面特效: - 滚动条:JavaScript可以控制页面滚动,如创建平滑滚动效果,或者自定义滚动条样式。 - 动态加载:通过...

    HTML基本标签+表格基础+表单和框架

    在“HTML基本标签+表格基础+表单和框架”这个主题中,我们将探讨这三个关键概念。 1. HTML基本标签:HTML标签是HTML语言的核心元素,它们告诉浏览器如何解析和展示页面内容。例如,`&lt;html&gt;`标签定义了整个文档的...

    Angularjs2表单和表格

    在AngularJS 2(现在称为Angular)中,表单和表格是构建动态用户界面的关键元素。Angular提供了强大的数据绑定和表单验证功能,使得开发者能够高效地处理用户输入和展示数据。下面我们将深入探讨AngularJS 2中表单和...

    javascript表格的渲染组件.docx

    JavaScript表格渲染组件是一种用于在网页中展示数据的高效工具,常用于数据分析、用户交互和信息展示。本篇文章主要探讨一个特定的JavaScript表格组件,它具备常见的功能如分页、搜索、删除以及AJAX操作,并使用...

    html静态网页(导航条、表格、表单、音视频插入、照片框等)

    HTML静态网页设计是Web开发的基础,它涉及到一系列的网页元素和功能,如导航条、表格、表单、音视频插入以及照片框等。这些元素在创建一个完整的、交互性强的网站时都起着至关重要的作用。 首先,让我们来讨论HTML5...

    HTML+JavaScript动态表格

    JavaScript则赋予了表格生命,使其能够响应用户的输入和操作。例如,使用事件监听器(如 `ondblclick`)可以捕捉到用户双击单元格的行为,然后执行相应的函数来改变单元格内容。此外,JavaScript还能实现数据验证,...

    js+html写的实现表格的动态增删改查和表单验证

    综上所述,使用JavaScript和HTML结合可以实现丰富的用户交互,创建动态表格并进行数据操作,同时配合表单验证保证数据质量。通过学习和掌握这些技能,开发者能够构建出高效、友好的前端应用。在实际项目中,还可能...

    javaScript对表格自动排序

    在网页中,JavaScript常用于交互式内容的创建,如动态表单、数据验证以及,如标题所述,表格的自动排序。下面我们将深入探讨如何使用JavaScript实现表格排序功能。 一、HTML表格基础 在HTML中,`&lt;table&gt;`元素用于...

Global site tag (gtag.js) - Google Analytics