Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by joe on Nov 20, 2009 10:19
open dhtmlx forum
dhtmlxCombo

Hello,
I have a problem with the dhtmlxCombo, I'm a beginner.

I load the combo with a XML, for example :
<?xml version="1.0" encoding="iso-8859-1" ?>
<complete>
<option value="10">10</option>
<option value="20">20</option>
<option value="50">50</option>
<option value="100">100</option>
</complete>

I load it in my page with this command :
var f=new dhtmlXCombo("combo_page2","alfa2",40);
f.loadXML("data.xml");

It loads the combo box but I am not having the first value selected. It starts with a blank element. I have a service that actually creates this xml and that service code I have some logic which I use to set one of the option as default selected but some times it is possible that no rule satisfies in the service and the selected="1" will not get set for any option in this case I want the combo box to set the first element as the default.

Thanks
Joe
Answer posted by Alex (support) on Nov 23, 2009 01:36

Hello,

you can use selectOption method to selectoption by index:

f.loadXML("data.xml",function(){

    f.selectOption(0);

});