当前位置: 代码迷 >> JavaScript >> javascript报表和表单
  详细解决方案

javascript报表和表单

热度:556   发布时间:2013-07-16 22:38:05.0
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>
  相关解决方案