Dynamically load select options

Hello,

I am stuck on a bit of functionality I’m hoping someone can help with. I am trying to load options to an existing select box with data from a jsonArray. I have tried using myForm.addItem() and myForm.reloadOptions(), but neither option is working as expected.

Any ideas on what I may be doing wrong, or is there a way to make it work properly?

Hello
First of all you need to chek if you have an extention dhtmlxform_dyn.js included.
There is no public method to add items in select, but i can share a demo with you with some features of work-around approach
13.10.28.rar (51.7 KB)

Yes I have dhtmlxform_dyn.js included. When using reloadOptions(), I have tried passing the function a string in both XML and JSON for data (options to add) and the error I get is this:

SCRIPT438: Object doesn’t support property or method ‘reloadOptions’

Please, provide us completed demo or direct link to reproduce this issue.
docs.dhtmlx.com/doku.php?id=othe … leted_demo

Try this:

[code]var opts = myForm.getOptions(‘select_id’);
var items = //Any Array;

for (i = 0; i < items.length; i++)
{
    if (items[i] != excludeId)
    {
        opts.add(new Option(items[i], items[i]));
    }
}[/code]

Locally this method and exention are working. Please attach demo to see the issue on your direct case.

Is this still an issue with version 4.1?

Hello, AakeTraak
It was question about 3.6 version

I know, that’s why I asked if this still is an issue in version 4.1.

Yes, of course!
Please, see delails
docs.dhtmlx.com/api__dhtmlxform_ … tions.html