reloadOptions not working

Hello, friends,

I can’t seem to get select control options to load from a PHP script.

First, here are the DHX libraries I’m using:



Here is the ‘select’ control definition from the form’s JSON:

{type: "select", inputWidth: 150, name: "buyers", label: "Buyer", connector: "http://intranet-dev/prBuyers.php"}

And here is the JavaScript code for loading the options:

bForm.reloadOptions("buyers", "http://intranet-dev/prBuyers.php");

The back-end PHP connector code, prBuyers.php, emits this string:

[{text:"Christopher Pike",value:""},{text:"Tiberius Kirk",value:""}]

But the ‘buyers’ select control options do not get populated. Nothing seems to happen.

However, if I change the JavaScript code to consume a hard-coded string:

bForm.reloadOptions("buyers", [{text:"Christopher Pike",value:""},{text:"Tiberius Kirk",value:""}]);

… the ‘buyers’ select control options get correctly populated.

Please help me find a solution. I’ve looked into the dhtmlxform_dyn.js extension library code, and the ‘dhtmlXForm.prototype.reloadOptions’ part seems to be getting executed. The value of the ‘name’ argument being passed to it is ‘buyers’, and the value of the ‘data’ argument being passed to it is ‘http://intranet-dev/prBuyers.php’. I assume this is as it should be.

Thank you.


Hello again,

I found this recent forum post:

I used a similar approach:"prBuyers.php", function(response){ bForm.reloadOptions("buyers", window.dhx4.s2j(response.xmlDoc.responseText)); });

… and it seems to work. However, the solution was provided by the poster and not by DHX staff. I would still like to know, please, if you have a different solution, especially since this one doesn’t appear to be documented for the ‘reloadOptions’ method.

Thank you again.


reloadOptions cannot be used with the separate pages and ajax requests. You can use only with the local objects.
So, as to the suggested solution, you need to perform the ajax-request to get the options as the local object and then use this object in the reloadOptions method.