Reputation: 1675
What i'm trying is to get the number of selected/checked items on a p:SelectManyCheckbox
:
This is what i've tried so far but i get always 1
on the console.
function hasSelectedItems() {
var iLen =document.getElementById("north_form:rvcombo").elements;
console.log(iLen.length);
};
This is my HTML :
<h:form id="north_form">
<p:selectCheckboxMenu id="rvcombo" widgetVar="rend" label="Rendez-vous" value="#{dyna.selectedstateOptions}" styleClass="combo" onHide="activateCounter();hasSelectedItems();" onShow="deactivateCounter();">
<f:selectItems value="#{dyna.etatExamOptions}" />
<p:ajax event="change" process="@this" partialSubmit="true" global="false"/>
</h:form>
</p:selectCheckboxMenu>
Upvotes: 0
Views: 1255
Reputation: 1949
var cnt = 0;
var o = document.getElementById("north_form:rvcombo").getElementsByTagName('input');
for ( var i in o ) {
if ( o[i].type=='checkbox' ) {
if ( o[i].checked ) {
cnt++;
}
}
}
return cnt;
Upvotes: 1