CRM-对列表元素进行多个选择
效果:
function doSelectAll(){
//prop jquery 1.6+建议使用
$("input[name=selectedRow]").prop("checked", $("#selAll").is(":checked"));
}
<table width="100%" border="0">
<tr class="t_tit">
<td width="30" align="center"><input type="checkbox" id="selAll" onclick="doSelectAll()" /></td>
<td width="140" align="center">用户名</td>
<td width="140" align="center">帐号</td>
<td width="160" align="center">所属部门</td>
<td width="80" align="center">性别</td>
<td align="center">电子邮箱</td>
<td width="100" align="center">操作</td>
</tr>
<s:iterator value="userList" status="st">
<tr <s:if test="#st.odd">bgcolor="f8f8f8"</s:if> >
<td align="center"><input type="checkbox" name="selectedRow" value="<s:property value='id'/>" /></td>
<td align="center"><s:property value="name"/></td>
<td align="center"><s:property value="account"/></td>
<td align="center"><s:property value="dept"/></td>
<td align="center"><s:property value="gender?'男':'女'"/></td>
<td align="center"><s:property value="email"/></td>
<td align="center">
<a href="javascript:doEdit('<s:property value='id'/>')">编辑</a>
<a href="javascript:doDelete('<s:property value='id'/>')">删除</a>
</td>
</tr>
</s:iterator>
</table>
数据提交时,action的处理:
public abstract class BaseAction extends ActionSupport {
protected String[] selectedRow;
public String[] getSelectedRow() {
return selectedRow;
}
public void setSelectedRow(String[] selectedRow) {
this.selectedRow = selectedRow;
}
}
可以得出一个结论, 对于提交数据时多个重名的name会构成一个数组进行封装。???