combo default value on page load

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" ?>



    10

    20

    50

    100





I load it in my page with this command :

var f=new dhtmlXCombo(“combo_page2”,“alfa2”,40);

f.loadXML(“data.xml”);



I would to set a default value when my page load for the first time but it depend of a php variable.



I try this for test (without my php variable) :

f.selectOption(1);



But this is not ok



I succed it when before this command I write an alert, for example:

alert(‘ok’);



Do you have a solution for me ?



Thank you


Hello,


The default option can be set in the xml by selected attribute:


20


Also you can select option by selectOption or setValue method after xml loading:


f.loadXML(“data.xml”,doAfterLoading)


function doAfterLoading(){


f.selectOption(1);


});

Ok, it works.
Thank you.