1. <p:column align="center">
<f:facet name="header">
<h:outputLabel value="Select" />
</f:facet>
<h:selectBooleanCheckbox id="select">
<p:ajax event="click" update="CoverageList,select" />
</h:selectBooleanCheckbox>
</p:column>
2.<p:column align="center">
<f:facet name="header">
<h:outputLabel value="#{label.coverage}" />
</f:facet>
<h:selectManyCheckbox id="CoverageList" style="width: 120px"
value="#{policy.selectedCoverageCodes}">
<f:selectItems value="#{policy.coverageCodes}" />
</h:selectManyCheckbox>
</p:column>
需要在点击单个复选框时选择多个复选框....
这是一个javascript版本
var elements = document.getElementsByTagName('input');
for(var i = 0; i< elements.length; i++) {
if (elements[i].type == "checkbox") {
elements[i].checked = !elements[i].checked;
}
}
如果你有jQuery使用这个
$("#CoverageList").click(function() {
var checked_status = this.checked;
$('#actions').find("input").each(function() {
$(this).prop("checked", checked_status);
});
});