Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
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")
);
User avatar
By adrienspth
#829053
Hello,

I have the same issue and that solve mine, but now i upgrade to processmaker 3.5.7 and it's doesn't work anymore.


This is my error : Uncaught TypeError: getFieldById(...).merge is not a function

And my code where it throw this error : getFieldById("hote_nom_equipement").merge(aOptions_nom_equipement);

The ID "hote_nom_equipement" is declare in my dynform.

I search into documentation about mergeOptions but i don't find anything worth.

Thanks for your help.

A 1xbet clone script is a pre-designed software so[…]

4rabet clone script is enabling entrepreneurs to e[…]

Parimatch clone script is enabling entrepreneurs t[…]

In the world of cryptocurrency, a wallet is an app[…]