<table style="color:#000;border-collapse: collapse;width: 100%;border-color: red;" border="1" >
<tr><th>序號</th><th>附件名</th><th>是否發送[全選<input type="checkbox" name="allCheck" value="111" onclick="doSelectAll(this);" /> ]</th></tr>
<span style="white-space:pre"> </span>
<span style="white-space:pre"> </span><% for(Iterator iterator = attachColl.iterator(); iterator.hasNext();){ attachIndex++;EntityMap attMap = (EntityMap) iterator.next();%>
<span style="white-space:pre"> </span><tr><td><%=attachIndex %></td><td align="left"><%=attMap.getJspString("fsfilename")%></td>
<span style="white-space:pre"> </span><td><input type="checkbox" name="atach" value="<%=attMap.getJspString("fsid")%>" /> </td> </tr>
<%} %>
</table>
JQuery代碼:
function doSelectAll(obj){
if($("input[name=allCheck]").get(0).checked){//點擊全選
$("input[name=atach]").each(function(){
$(this).attr('checked', true);
});
}else{//取消全選
$("input[name=atach]").each(function(){
$(this).attr('checked', false);
});
}
}