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.
By PipSqueak
#815556
I have a grid that allows users to upload files, but only one of the rows need to be checked.

1) How do I validate it by column instead of each field?
2) How do I also limit one file to be uploaded in each row?
2018-08-06 16_37_46.png
2018-08-06 16_37_46.png (9.2 KiB) Viewed 2839 times
Thanks
#815597
You can edit the source code to prevent more than one file being uploaded in a MultipleFile field. Change the maxFiles variable in this code.

The problem is that these code changes effect all MultipleFile fields in your installation of ProcessMaker. Sorry, I don't have a solution, except to use File fields instead of MultipleFile fields.

I have created a form that shows how to limit a grid to only one marked checkbox:
(2.66 KiB) Downloaded 262 times
#815608
I used your code, but couldn't get it to work. It worked when I imported your form and used it without any modification, but when I copied and pasted your form, it doesn't.....

Code: Select all
////only execute if a main form, and not a Subform - Start
var form = "#4149780275b45ba187be067067584618";
if ($(form).prop("tagName") == "FORM") {

////---MODIFICATION TO QUOTES GRID---////
var gridId = 'gridQuotes'; //set to ID of grid
//var fieldId = 'strgCosts'; //set to ID of text field inside grid


  ////---FIX NUMBER OF ROWS ON QUOTES GRID---////
   var nRowsNeeded1 = 3 - $('#'+gridId).getNumberRows();
  if (nRowsNeeded1 > 0) {
     for (i=0; i < nRowsNeeded1; i++) {
        $('#'+gridId).addRow();
     }
  }
  else if (nRowsNeeded1 < 0) {
     for (i=0; i > nRowsNeeded1; i--) {
        $('#'+gridId).deleteRow();
     }
  }

////----ONLY ALLOW ONE CHECKBOX IN COLUMN----////
//var gridId = "gridQuotes"; //set to the ID of grid
var gridCheckboxId = "strgQuotesTopChoice"; //set to the ID of the grid's checkbox 
var gridCheckboxColNo = 1; //set to the column number of the grid's checkbox 

var reGridCheckbox = new RegExp("^\\["+gridId+"\\]\\[(\\d+)\\]\\["+gridCheckboxId+"\\]$");
//var formId = $($form).prop("id");

$(form).setOnchange( function(fieldId, newVal, oldVal) {
  var aMatches = fieldId.match(reGridCheckbox);
                               
  if (newVal == '"1"' && aMatches) {
    var currentRowNo = aMatches[1];
    var rowMarked = 0;
    var rowCount = $("#"+gridId).getNumberRows();
    
    for (var i = 1; i < rowCount; i++) {
      if (i != currentRowNo && $("#"+gridId).getValue(i, gridCheckboxColNo) == "1") {
        alert("Checkbox in row "+i+" is already marked.");
        $("#"+gridId).setValue("0", currentRowNo, gridCheckboxColNo);      
      }
    }
  }
});


////only execute if a main form, and not a Subform - End
}
  
////----HIDE/SHOW FIELDS IF strCapitalExpense CHANGES----/////

$('#strAllPartial').hide();
$('#strCostRecoveryMethod').hide();
$('#strRecoverableCost').hide();
$('#strEstimatedEarningsSavings').hide();
$('#subtitleEstimatedEarningsSavings').hide();
$('#strAllPartial').disableValidation();
$('#strCostRecoveryMethod').disableValidation();
$('#strRecoverableCost').disableValidation();
$('#strEstimatedEarningsSavings').disableValidation();

  $('#strCapitalExpense').setOnchange(function(newValue, oldValue) {
    //if value is not 'Expense'
    if (newValue != 'Expense') {
      $('#strAllPartial').show();
      $('#strCostRecoveryMethod').show();
      $('#strRecoverableCost').show();
      $('#strEstimatedEarningsSavings').show(); 
      $('#subtitleEstimatedEarningsSavings').show();
      $('#strAllPartial').enableValidation();
      $('#strCostRecoveryMethod').enableValidation();
      $('#strRecoverableCost').enableValidation();
      $('#strEstimatedEarningsSavings').enableValidation();
    }
    else {
      $('#strAllPartial').hide();
      $('#strCostRecoveryMethod').hide();
      $('#strRecoverableCost').hide();
      $('#strEstimatedEarningsSavings').hide();
      $('#subtitleEstimatedEarningsSavings').hide();
      $('#strAllPartial').disableValidation();
      $('#strCostRecoveryMethod').disableValidation();
      $('#strRecoverableCost').disableValidation();
      $('#strEstimatedEarningsSavings').disableValidation();
    }
  });

Hello. For rental housing, there are software solu[…]

Experience heightened pleasure with Cenforce 100 M[…]

Get an instant solution to move emails to MBOX for[…]

Most Demanding OST to PST Converter

The most demanding OST to PST Converter is TrijaT[…]