Search code examples
comboboxdhtmlx

Can't load options into dhtmlxCombo


Can't load options into dhtmlxCombo. I try the following:

myForm = new dhtmlXForm("dhtmlxForm"); 
myForm.loadStruct("codebase/form.xml"); 
var combo = myForm.getCombo("xVolumeStatus");
combo.load("codebase/options.xml");
combo.selectOption(2, false, true);

But combo is undefined


Solution

  • You forget callback. Twice  It must be:

    myForm.attachEvent("onXLE", function() {
        var combo = myForm.getCombo("xVolumeStatus");
        combo.load("codebase/options.xml", function(){
            combo.selectOption(2, false, true);
        });
    });
    

    First you getting combo when form is loaded, then you select option when combo options are loaded.