dhtmlxCombo Checkbox

Hello,



How can i get number of elements on dhtmlxCombo (Checked and no Checked) ? length ?



Thanks

Best regards



Ke


Hello


there isn’t a method to get a total number of options. But it can be done using optionArr private property:


var total_number = combo.optionsArr.length; /combo is combo object/


The getChecked() method return array with values of checked options. So, number of checked elements is:


var checked_arr = combo.getChecked();


var checked_number = checked_arr.length;


Ok, thanks you,



 



other question, can we add a checkbox TOTAL to checked all the checkbox on a combo ?


Combo doesn’t provide API to check option.


But you can try to use the following method that allows to check/uncheck all options in combo in TOTAL option is checked/unchecked:


combo.attachEvent(“onCheck”,function(val,state){


if(val==“total”){
for(var i = 0; i < this.optionsArr.length; i++){
if(this.optionsArr[i].value!=“total”)
this.optionsArr[i].content.firstChild.checked = state;
}
}
return true

})


Where “total” is value of the “TOTAL” option.