ProcessMaker code contributions

Moderator: amosbatto

By sabinsunny
#790009
Hi Team, Today i need a java script

i have a dropdown list and and a textbox;
i need to display the value in textbox which i select in the dropdown list.
By amosbatto
#790012
Do you want the value of the selected option in the dropdown or its label?

To copy the value of the selected option, do this:
Code: Select all
$("#mydropdown").setOnchange( function (newVal, oldVal) {
    $("#mytextbox").setValue(newVal);
});
If you need the label of the selected option, then do this:
Code: Select all
$("#mydropdown").setOnchange( function (newVal, oldVal) {
    var aOptions = $("#mydropdown").getInfo().options;
    for (var i in aOptions) {
        if (aOptions[i].value == newVal) {
            $("#mytextbox").setValue(aOptions[i].label);
            break;
        } 
    }        
});
Where "mydropdown" is the ID of your dropdown and "mytextbox" is the ID of your textbox.
Import this DynaForm for an example:
(2.31 KiB) Downloaded 51 times
By sabinsunny
#790020
Hi amosbatto ,
Thank You So Much,

Here i need another coding also

need to take substring from one dropdown box value to another textbox
Attachments
string.png
string.png (1.08 KiB) Viewed 1096 times
DropBox.png
dropdownn box
DropBox.png (3.57 KiB) Viewed 1096 times
By mishika
#790022
Hello,

To add a substring to another text box, you can make a little modification to the code given by Amos.
Code can be as follows:
Code: Select all
$("#mydropdown").setOnchange( function (newVal, oldVal) {
  var aOptions = $("#mydropdown").getInfo().options;
  for (var i in aOptions) {
    if (aOptions[i].value == newVal) {
      $("#mytextbox").setValue(aOptions[i].label);
      var lab = aOptions[i].label;	//take the label
      var res = lab.split("-");		//split and get an array
      $("#mytextbox1").setValue(res[1]); 	//assign a value from array to a textbox
      break;
    }
  } 
});
You can use .split function to break the string on the basis of a connector like -, ., _ etc.
You can also use .substring function where you will have to pass the starting index and the ending index of the string to be selected from the main string.

Hope this helps

Best Regards
Mishika
Send for clarification

Cost: Will you be using PM entrerprise or open sou[…]

SMS Gateway

Hello natesh, I have a Get ready to use integrate[…]

delete information after CSV export

thanks for your attention, i have some change on y[…]

Thanx again amosbatto... I'll re-check file permis[…]