我想要一列复选框来选择多行。我设法在每一行上创建了一个复选框,但我还希望在标签上有一个复选框,以便当我选中标题上的复选框时它会自动选择列上的所有复选框。我怎么能做到这一点?
PS:我使用JSP
<form id="form">
<div style="text-align:right; padding-bottom:1em;">
<button type="submit">Submit form</button>
</div>
<datatables:table id="owners" data="${selections}" row="owner" theme="bootstrap2"
cssClass="table table-striped" pageable="false" info="false" export="pdf">
<datatables:column title="Name" cssStyle="width: 150px;" display="html">
<spring:url value="/owners/{ownerId}.html" var="ownerUrl">
<spring:param name="ownerId" value="${owner.id}"/>
</spring:url>
<a href="${fn:escapeXml(ownerUrl)}"><c:out value="${owner.firstName} ${owner.lastName}"/></a>
</datatables:column>
<datatables:column title="Name" display="pdf">
<c:out value="${owner.firstName} ${owner.lastName}"/>
</datatables:column>
<datatables:column title="Address" property="address" cssStyle="width: 200px;"/>
<datatables:column title="City" property="city"/>
<datatables:column title="Telephone" property="telephone"/>
<datatables:column title="Pets" cssStyle="width: 100px;">
<c:forEach var="pet" items="${owner.pets}">
<c:out value="${pet.name}"/>
</c:forEach>
</datatables:column>
<datatables:column sortable="false" filterable="false">
<input type="checkbox" name="check${owner.id}" value="${owner.id}">
</datatables:column>
<datatables:export type="pdf" cssClass="btn" cssStyle="height: 25px;" />
</datatables:table>
</form>