<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
<title>使用复选框控制表格中的文本框</title>
<script language="javascript">
function chkOper(chk)
{
var inputs = chk.parentNode.parentNode.cells[1].getElementsByTagName("input"); //通过父级节点获取输入框
var status = chk.checked; //判断复选框是否选中的变量
for(var i=0,j=inputs.length;i<j;i++) //遍历每个input控件
inputs[i].disabled = status; //通过复选框的值设置每个input控件的可用性
}
</script>
</head>
<body>
<table width="500" border="1" cellspacing="1" cellpadding="1">
<tr>
<td width="40px" align="center">
<input type="checkbox" name="checkbox" id="" οnclick="chkOper(this)"/></td>
<td width="230px">
<input type="text" name="textfield" id="Text1" />
</td>
<td width="230px"><a href="http://www.youweishop.com">有为商城</a></td>
</tr>
<tr>
<td align="center"><input type="checkbox" name="checkbox" id="Checkbox1" οnclick= "chkOper(this)"/></td>
<td><input type="text" name="textfield2" id="textfield2" /></td>
<td><a href="http://tg.youweishop.com">有为团购</a></td>
</tr>
<tr>
<td align="center"><input type="checkbox" name="checkbox" id="Checkbox2" / οnclick= "chkOper(this)"></td>
<td><input type="text" name="textfield3" id="textfield3" /></td>
<td><a href="http://news.youweishop.com">有为门户</a></td>
</tr>
</table>
</body>
</html>