Questions and discussion about using ProcessMaker: user interface, running cases & functionality

Moderator: amosbatto

User avatar
By kram327
I'm looking for a way to change the default value of a drop-down field (Purpose) based on another dropdown field (Facility). The idea is to auto populate the commonly selected value for specific facility type, and can change later on if ever the actual value is different from the default value.

I tried using the setValue function but it will not allow to change value anymore.
Code: Select all
	var nRow = $("#GRID_FACILITY").getNumberRows();
	for (; nRow >= 1; nRow--) {
  		if ($("#GRID_FACILITY").getValue(nRow, 2) == 'Term Loan') {
			$("#GRID_FACILITY").setValue("For capital expenditures", nRow, 6);
Found the following in wikipedia, however, i can't follow the instructions:
Code: Select all
PM1.jpg (32.64 KiB) Viewed 297 times
User avatar
By amosbatto
You have to use form.setOnchange() for this. See: ... s_in_grids

Let's assume that the ID of grid is "loadFacilityGrid" and the IDs of your dropdowns are "facility" and "purpose", then your JavaScript code would be something like this:
Code: Select all
var formId = $("form").prop("id");

$("#"+formId).setOnchange( function(fieldId, newVal, oldVal) {
   var aMatch = fieldId.match(/^\[loanFacilityGrid\]\[(\d+)\]\[facility\]$/);
   //if the "facility" field was changed in the grid, then change the value of the "purpose" field:
   if (aMatch) {
      var rowNo = aMatch[1];
      if (newVal == 'term_load') {
           setValue("capital_expenditures", rowNo, 5);
Remember that you are checking for the values (not the displayed labels) in the dropdowns.
User avatar
By kram327
Thanks for looking at this, Amos. However, I can't get it to work :(.
Maybe it's not working since I have 2 subforms in the dynaform.

I saw this code in the link that you have provided but didn't work as well:

$("#form\\[loanFacilityGrid\\]\\[2\\]\\[facility\\]").change( function() {
} );
User avatar
By amosbatto
JavaScript isn't executed when placed in a subform. You have to put the JavaScript in the parent Dynaform if you want it to execute. If you still can figure it out, then post the .json files for your parent Dynaform and your subforms.
User avatar
By kram327
Hi Amos,

Kindly see attachment.

I have tried the code below you have provided in a different thread. It works but I can't edit the values anymore.

Code: Select all
$("#1370990845d01cc5967f945040421865").change( function(e) {
function OMNIBUS(e) {
	var nRow = $("#GRID_OMNI_FACILITY").getNumberRows();

	for (; nRow >= 1; nRow--) {
  		if ($("#GRID_OMNI_FACILITY").getValue(nRow, 2) == 'Loan Line') {
			$("#form\\[GRID_OMNI_FACILITY\\]\\[" + nRow + "\\]\\[OMNI_AVAILABILITY\\]").attr("disabled", false);
			$("#form\\[GRID_OMNI_FACILITY\\]\\[" + nRow + "\\]\\[OMNI_TR_TERM\\]").attr("disabled", true);
			$("#form\\[GRID_OMNI_FACILITY\\]\\[" + nRow + "\\]\\[OMNI_FREE_FLOAT\\]").attr("disabled", true);
			$("#form\\[GRID_OMNI_FACILITY\\]\\[" + nRow + "\\]\\[OMNI_TENOR\\]").attr("disabled", true);
			$("#form\\[GRID_OMNI_FACILITY\\]\\[" + nRow + "\\]\\[OMNI_TERM\\]").attr("disabled", true);
			$("#form\\[GRID_OMNI_FACILITY\\]\\[" + nRow + "\\]\\[OMNI_PN_TERM\\]").attr("disabled", false);
			$("#form\\[GRID_OMNI_FACILITY\\]\\[" + nRow + "\\]\\[OMNI_REPAYMENT\\]").attr("disabled", true);
			$("#form\\[GRID_OMNI_FACILITY\\]\\[" + nRow + "\\]\\[OMNI_PRINCIPAL_REPAYMENT\\]").attr("disabled", false);
			$("#form\\[GRID_OMNI_FACILITY\\]\\[" + nRow + "\\]\\[OMNI_INTEREST\\]").attr("disabled", false);
			$("#form\\[GRID_OMNI_FACILITY\\]\\[" + nRow + "\\]\\[OMNI_FX_RATE\\]").attr("disabled", true);
			$("#GRID_OMNI_FACILITY").setValue("Via Peso / Dollar PN", nRow, 7);
			$("#GRID_OMNI_FACILITY").setValue('', nRow, 8);
			$("#GRID_OMNI_FACILITY").setValue('', nRow, 9);
			$("#GRID_OMNI_FACILITY").setValue('', nRow, 10);
			$("#GRID_OMNI_FACILITY").setValue('', nRow, 11);
			$("#GRID_OMNI_FACILITY").setValue("Up to ____ days; renewable / extendible for another ____days\n\n\(Note if with assignment, Tenor: Co-terminus with contract date)", nRow, 12);
			$("#GRID_OMNI_FACILITY").setValue('', nRow, 13);
			$("#GRID_OMNI_FACILITY").setValue("", nRow, 14);
			$("#GRID_OMNI_FACILITY").setValue("Prevailing SBC lending rate; subject to _____ (monthly or periodic) setting and payment in ____(arrears or in advance)", nRow, 15);
			$("#GRID_OMNI_FACILITY").setValue('', nRow, 16);
			$("#GRID_OMNI_FACILITY").setValue('', nRow, 17);
(8.21 KiB) Downloaded 4 times
(11.42 KiB) Downloaded 4 times
(11.87 KiB) Downloaded 4 times
(88.06 KiB) Downloaded 4 times
User avatar
By kram327
Hi Amos,

:D I got it working, but I don't know how to incorporate the first line in your initial recommendation: "var formId = $("form").prop("id");"

4176592055d01e398556d81061810704 is the subform ID

$("#4176592055d01e398556d81061810704").setOnchange( function(fieldId, newVal, oldVal) {
var aMatch = fieldId.match(/^\[GRID_NON_FACILITY\]\[(\d+)\]\[NON_FACILITY\]$/);
if (aMatch) {
var nRow = aMatch[1];
if (newVal == 'TERM LOAN') {
$("#form\\[GRID_NON_FACILITY\\]\\[" + nRow + "\\]\\[NON_FACTOR_RATE\\]").attr("disabled", true);
$("#form\\[GRID_NON_FACILITY\\]\\[" + nRow + "\\]\\[NON_DISCOUNT_CHARGE\\]").attr("disabled", true);
$("#form\\[GRID_NON_FACILITY\\]\\[" + nRow + "\\]\\[NON_SERVICE_CHARGES\\]").attr("disabled", true);

$("#GRID_NON_FACILITY").setValue("For capital expenditures", nRow, 5);
$("#GRID_NON_FACILITY").setValue('', nRow, 6);
$("#GRID_NON_FACILITY").setValue('', nRow, 7);
User avatar
By amosbatto
This line is just to get the ID of the form:
var formId = $("form").prop("id");

but it is better to set the ID in your code if the ID won't change. In your case you should set the ID since you have multiple forms:
var formId = '1234567890abcde1234567890abcde';

Yeah That will be very helpful :) Thank you

variable in external libs

Ohhh I tried this thing before but didn't work tha[…]

Limit List box

Hello Amos, The following solution is working. $[…]

It looks like jquery.masknumber.js has problems in[…]