var z=new dhtmlXCombo("combo_zone3","alfa3",200);
z.addOption(value,label,css);
value - value of option
label - label of option
css - css string attached to option, optional
It is possible to add few options at once
var z=new dhtmlXCombo("combo_zone3","alfa3",200);
z.addOption([[value,label,css],[value2,label2,css3],[value3,label3,css3]]);
From XML file
var z=new dhtmlXCombo("combo_zone3","alfa3",200);
z.loadXML("xml/data.xml");
Where XML is have next format
Possible attributes of <option> tag:
dhtmlxcombo automatically integrates in surrounding FORM tag.
While submitting such form, there are two form wields will be sent to server side
COMBONAME - value of combobox
COMBONAME_new_value - true if value is text entered in combobox, false if value one of items from predefined list. of combobox
If combo will be initialized by next command
var z=new dhtmlXCombo("combo_zone3","alfa3",200);
server side script will receive fields with names "alfa3" and "alfa3_new_value"
dhtmlxcombo can work in filtering mode. In such mode the values in list filtered by current entered text in edit control.
To enable filtration next command can be called
z.enableFilteringMode(true);
By default combobox uses options which already loaded in it, but it is possible to define the external script
which will be called for generating list of suggestion.
z.enableFilteringMode(true,"php/complete.php",cache);
php/complete.php - path to script
cache - true/false - enable/disable caching of script responses ( using "true" recommended )
In described situation, for each change of text in edit control the next url will be called
php/complete.php?pos=0&mask=TEXT
TEXT - current text in edit control
The combobox awaits that script response will be a XML in same format which used for initialization.
If you prefer - you can return only part of suggestion, combobox can automatically send additional request and add more data to list of options.
z.enableFilteringMode(true,"php/complete.php",cache,true);
The server side script will be called by url
php/complete.php?pos=START&mask=TEXT
START - position from which suggestion must be returned.
For all additional sub fetches returned XML must have "add" attribute of main tag
...
Groups extension allows to organize groups of combos with parent-child dependence, when options of child combos are determined by the value of selected option in its parent.
Method attachChildCombo(child_combo,url) defines a child combo and sets a path to a server-side script which generates a necessary xml.
var z2=new dhtmlXCombo("combo_zone2","alfa2",200);
var z=new dhtmlXCombo("combo_zone","alfa1",200);
z.enableFilteringMode(true);
z.attachChildCombo(z2,"combo2.php");
z.loadXML("combo1.xml");
When some option is selected in the parent combo. The server-side script ("combo2.php" in the example above) recieves the value of this option with the request; the name of this parameter is "parent". Such a functionality allows to form xml stream depending on parent's value using any server-side language.
combo2.php?parent=PARENT_VALUE
Child combos can be set in the same container with their parent using setAutoSubCombo(url,name). In this case, they inherit all methods and properties of the parent, except the server-side script and the name which are set in the setAutoSubCombo method.
var z1=new dhtmlXCombo("combo_zone1","alfa1",200);
z1.enableFilteringMode(true);
z1.loadXML("combo1.xml")
var z2 = z1.setAutoSubCombo("combo2.php","alpha2")
var z3 = z2.setAutoSubCombo("combo3.php","alpha3")