Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderator: amosbatto

Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
User avatar
By rymrbh
#790150
Hello,

In a dynaform, I want to fill dynamically a dropdown menu.

I have an initial dropdown menu with a list of hosts, when I select one host some javascript is executed to get from an api a list of IP addresses. And I want to fill my second dropdown menu with those IP addresses. They are in a string variable returned by a php code .

I tried to do it using this doc http://wiki.processmaker.com/3.0/Dropdo ... pt_Methods but it's not working.

Thanks for your help.
User avatar
By amosbatto
#790161
You can use mergeOptions() for this in JavaScript.
See: viewtopic.php?f=47&t=710111
Your JavaScript code in the DynaForm will be something like this:
Code: Select all
$("#dropdown1").setOnchange( function(newVal, oldVal) {
    var aOptions = $("#dropdown2").getInfo().options;
    aOptions.push( {"value": newVal,  "label": newVal} );
    getFieldById("dropdown2").mergeOptions(aOptions);
});
To set the list of options in the first dropdown, set it datasource property to "array variable" then set the array variable property to @=myArray. Then, create a Trigger executed before the DynaForm to set the list of options in @=myArray:
Code: Select all
@=myArray = array(
    array("http://www.example1.com", "http://www.example1.com"),
    array("http://www.example2.com", "http://www.example2.com"),
    array("http://www.example3.com", "http://www.example3.com")
);
BPMN project disappeared

Hi there, I'm new with ProcessMaker, using commu[…]

Hello, Since the web site "https://www.pmuse[…]

Same issue as here.. there was no problem on the l[…]

Hello, Since a while, the link "https://www.[…]