How to get count of Combo Options

Please can you tell me if there is a way of getting a count of the number of options in a Combo.



There is not a public method. Try to use the following approach:

var count = combo.optionsArr.length;

optionsArr - collection of combo options.

Hi Alexandra sorry for the delay in acknowledging your message. Thanks very much that worked well. Please can you tell me what getOptionByIndex() is supposed to return.



getOptionByIndex(index) return option object. You may get value and text properties of this object:

var option = combo.getOptionByIndex(index);
var value = option.value;
var text = option.text;

Thanks Alexandra. Once again a really nice feature but not properly documented. You guys should team up with someone and get a proper user manual written.

Any way thanks.


Hi guys,

I’m trying to get the count of options in the dhtmlxcombo object.
I used the code but it gives me 0 when there are options in it.

dhxComboUsr.clearAll(true); //clear selected user
dhxComboUsr.loadXML("<?php echo site_url('qmsdhx/getallusrxml'); ?>/");

Is the optionsArr property obsolete now ??

Did you try to ue aftercall?

dhxComboUsr.loadXML("<?php echo site_url('qmsdhx/getallusrxml'); ?>/", function(){

Never mind. I figured it out.
Its because the function is async. I used the callback function in loadxml and it worked.
Great framework !!

Spicebo Darya,

I did not see your post. Thank you for your help :slight_smile:

You are welcome!