How to set a default text and value?

Hello!

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?

Thanks!

Any answer for me? :confused:

Hello
If you have combo loaded from array of objects:
dhtmlx.com/docs/products/dhtmlxC … 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:
dhtmlx.com/docs/products/dhtmlxC … lient.html

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

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

Great!!
Works fine, thanks!! :smiley:

You are welcome!