Set option after loading dhtmlxCombo options from a XML file

First of all thanks for your great JS components



On our website I use a dhtmlxCombo which is loaded from an XML file. When a user enters the page he/she has sometimes already entered a value which we store in a database corresponding to the option value in the XML file. After loading the options into the dhtmlxCombo I would like to set the selected option. One way is to modify the XML to have a SELECTED value. Is there a nother way?



XML example

<?xml version="1.0" ?>



    Pictograms

    

    

    

    

    

    

    





Could you please avise me how to set the option of the dhtmlxCombo corresponding to the value in the database?



I have tried the following selectOption method and I have hardcoded index 2, but it does not update:

response.Write “var z”&isignmessageid&"=new dhtmlXCombo("""&isignmessageid&""","""&isignmessageid&""",105, ‘image’);"

response.Write “z”&isignmessageid&".loadXML(""…/XMLPictograms/Pictogram1.xml"");"

response.Write “z”&isignmessageid&".selectOption(2);"



Kind regards

Niels


The problem caused by async. way of XML loading, the command next to loadXML will be executed when data is not loaded yet



You can use second parameter of loadXML function to catch the moment, when data already loaded and option can be selected



response.Write “z”&isignmessageid&".loadXML(""…/XMLPictograms/Pictogram1.xml"",function(){"
response.Write “z”&isignmessageid&".selectOption(2);"
response.Write “});”


That worked perfect! Thank you very much!



kind regards



Niels