jsp页面代码:
<script src="${basepath}/js/common.js" type="text/javascript"></script>
<table>
<thead>
<tr>
<th>
<input type="checkbox" id="chk_all" name="chk_all" οnclick="javascript:checkAll(this,'ids');" />
全选
</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="checkbox" value="${product.pId}" name="ids" id="ids" /></td>
</tr>
</tbody>
</table>
js代码:
function checkAll(e, itemName)
{
var aa = document.getElementsByName(itemName);
for (var i = 0; i < aa.length; i++)
aa[i].checked = e.checked;
}