在表格中复选框选择、选中后变色
<style type="text/css">
<!--
.row {BACKGROUND-COLOR: expression(rowIndex%2==1?'':'#F5F5F5')}
Body {FONT-SIZE: 12px; FONT-FAMILY: Arial,Verdana,sans-serif;LINE-HEIGHT: 150%;}
Td {FONT-SIZE: 12px; FONT-FAMILY: Arial,Verdana,sans-serif;LINE-HEIGHT: 150%;}
.tb {border-collapse: collapse}
-->
</style>
<script language="JavaScript" type="text/JavaScript">
//复选
function selectAll(chk)
{
var chk = document.form1.chkAll.checked;
for (i=0;i<document.all.length;i++) {
if (document.all[i].name=="id[]") {
document.all[i].checked=chk;
chkRow(document.all[i]);
}}}
//复选后单元格变色
function chkRow(obj){
var r = obj.parentElement.parentElement;
if(obj.checked){ r.style.backgroundColor="#E6E9F2";}
else {if(r.rowIndex%2==1)r.style.backgroundColor="";else r.style.backgroundColor="#F5F5F5";}
}
</script>
<table width="50%" border="1" cellpadding="3" cellspacing="0" bordercolor="#333333" method="post" action="">
<tr align="center"><strong>网站名称</strong></td>
<td width="62%" align="center"><strong>网 址</strong></td>
</tr>
<tr name="id[]" value="1" onclick="javascript:chkRow(this);"></td>
<td align="center">凤凰网</td>
<td align="center">www.ifeng.com</td>
</tr>
<tr name="id[]" value="1" onclick="javascript:chkRow(this);"></td>
<td align="center">腾讯网</td>
<td align="center">www.qq.com</td>
</tr>
<tr name="id[]" value="1" onclick="javascript:chkRow(this);"></td>
<td align="center">环球网</td>
<td align="centerwww.huanqiu.comdesign</td>
</tr>
<tr name="chkAll" title="全选/取消" onclick="selectAll()"> <strong>全选/取消</strong></td>
</tr>
</form>
</table>