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.

Thanks

Purvez

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.

Thanks
Purvez

Hi,

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.

Purvez

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'); ?>/");
alert(dhxComboUsr.optionsArr.length);

Is the optionsArr property obsolete now ??

Hi
Did you try to ue aftercall?

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

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!