<html>
<head>
<title></title>
<meta http-equiv='Content-Type' content='text/html; charset=gb2312' />
</head>
<body>
<script>
function select_all(form, s, sel)
{
for (var i=0;i<form.elements.length;i++)
{
var e = form.elements[i];
if (e.name.substring(0, sel.length) == sel)
e.checked = s.checked;
}
}
</script>
<table width="500" border="1">
<form name="test_form" id="test_form">
<tr>
<td width="71"><label for="sel_all"><input type="checkbox" name="sel_all" id="sel_all" value="1"
οnclick="select_all(document.test_form, this, 'item_')"/>
全选</label></td>
<td width="413">title</td>
</tr>
<tr>
<td><input type="checkbox" name="item_1" value="checkbox" /></td>
<td>item 1</td>
</tr>
<tr>
<td><input type="checkbox" name="item_2" value="checkbox" /></td>
<td>item 2 </td>
</tr>
<tr>
<td><input type="checkbox" name="item_3" value="checkbox" /></td>
<td>item 3 </td>
</tr>
</form>
</table>
</body>
</html>
--------------------------------------------------------------------------------------------
<html>
<head>
<title></title>
<meta http-equiv='Content-Type' content='text/html; charset=big5' />
</head>
<script language="javascript">
function chkAll_onclick(){
if(typeof(form1.chkAccount) == "object"){
if(form1.chkAllAccount.checked){
SelAll();
}
else{
unSelAll();
}
}
}
function SelAll(){
var intCount;
var result="";
if(form1.all("chkAccount").length > 1)
{
for(intCount = 0; intCount < form1.all("chkAccount").length; intCount++)
{
form1.chkAccount(intCount).checked = true;
result=result+form1.chkAccount(intCount).value+";";
}
}
else{
form1.chkAccount.checked = true;
}
alert("你選中的是:"+result);
}
function unSelAll(){
var intCount;
if(form1.all("chkAccount").length > 1)
{
for(intCount = 0; intCount < form1.all("chkAccount").length; intCount++)
{
form1.chkAccount(intCount).checked = false;
}
}
else{
form1.chkAccount.checked = false;
}
}
</script>
<body>
<form name="form1" method="post" action="">
<input name="chkAccount" type="checkbox" value="人民"/>人民
<input name="chkAccount" type="checkbox" value="中國"/>中國
<input name="chkAccount" type="checkbox" value="你好"/>你好
<input name="chkAccount" type="checkbox" value="公園"/>公園
<input name="chkAccount" type="checkbox" value="長江"/>長江
<input name="chkAccount" type="checkbox" value="黃河"/>黃河
<input type="checkbox" name="chkAllAccount" value="ON" title="全部選中" οnclick="chkAll_onclick()">全部選中
</form>
</body>
</html>