How to set a default text and value?


I searched the forum, but did not find my answer. I use the dhtmlXCombo in a product editing from. I need to put the value selected previously. I use the setComboText and setComboValue methods, but it’s the text displayed that my form receives, not the value, wich is the product ID.

How can I make this works?


Any answer for me? :confused:

If you have combo loaded from array of objects: … jects.html

myCombo.addOption([ {value: "1", text: "Walking through the city", css: "color:red;", selected: true}, {value: "2", text: "Looking oh so pretty", css: "color:green;"}, ... ]);
If from json: … lient.html

myCombo.load({options:[ {value: "1", text: "Copenhagen Airport"}, {value: "2", text: "Dublin Airport", selected: true}, ... ]});
If from xml: … lient.html

<complete> <option value="1"><![CDATA[Copenhagen Airport]]></option> <option value="2" selected="1"><![CDATA[Dublin Airport]]></option> ... </complete>

Works fine, thanks!! :smiley:

You are welcome!