Form ->combo -> ajax question

I am trying to solve a problem fr a day now and i am almost done. I have three combos in a form. When I select the first two an ajax request goes out to a mysql database and sends back this xml:

<complete><option value='1'><![CDATA[1]]></option><option value='2'><![CDATA[2]]></option><option value='3'><![CDATA[3]]></option><option value='4'><![CDATA[4]]></option></complete>

I would like to use this ajax output to populate my third combo box. I am pretty sure that it’s easy, but i was not able to do it. Bear in mind that updateOption did not work for me in the form.
Thanks for the help

I found the reloadOptions function for forms. However, I cannot use the ajax loader.xmlDoc.responseText as the second argument for the reloadOption function. It thinks that the XML output is a URL.

My basic question is this. I generate an xml output by Ajax. How can i populate a combo or select item on a form dynamically with it. I am really frustrated that I still has not been able to solve it.


to reload combo options you can use the following approach:


If loadXML method for some reason does not fit, you can use own approach to load data. And if it is an xml, you can use loadXMLString, in case of json result - addOption:
combo.addOption([{value:1,text: “text 1”},{value:2, text: “text 2”}, …]);

Options reloading can be called from onChange event handler:


I define my combos in the from with an xml file:

<?xml version="1.0"?> <items> <item type="combo" name="freezer" connector="php/comboFreezer.php" label="Freezer" labelWidth="200" inputWidth="200" /> <item type="combo" name="box" connector="php/comboBox.php" label="Box" labelWidth="200" inputWidth="50" /> <item type="combo" name="location" label="Location" labelWidth="200" inputWidth="150" /> </items>
I am trying to use the combo functions
however, I cannot address the combos that I defined in the form. I tried to look through all the documentation and samples, and I have not found an example addressing the issue with combos defined in forms.

I tried to use getCombo function like this:

//the Form var comboForm; dhtmlxEvent(window, "load", function () { comboForm = comboLayout.cells("a").attachForm(); comboForm.loadStruct("xml/comboform.xml"); comboFreezer = comboForm.getCombo("freezer"); comboFreezer.clear(); });

I get an error message of

Uncaught TypeError: Cannot call method ‘clear’ of null


problem the same as here viewtopic.php?f=17&t=33934