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 vahid2231
#828514
Hello friends
I want to disable a text box using the drop-down list
But this code does not work and just disables but can not activate
Code: Select all
//when the Dynaform loads, pass through the grid and disable or enable the discountRate field 
//in each row, depending on the value of the hasDiscount field.
var nRows = $("#equipmentList").getNumberRows(); 

for (i = 1; i <= nRows; i++) {
  var hasDiscount = $("form\\[equipmentList\\]\\["+i+"\\]\\[hasDiscount\\]").val();
  
  if (hasDiscount == "Discount") {
    $("#form\\[equipmentList\\]\\["+i+"\\]\\[discountRate\\]").prop("disabled", false);
  }  
  else {   // if "No Discount":
    $("#form\\[equipmentList\\]\\["+i+"\\]\\[discountRate\\]").prop("disabled", true);
  }
}

//when a new row is added to the grid, disable the discountRate field by default.
$("#equipmentList").onAddRow( function(aNewRow, oGrid, rowIndex) {
  $("#form\\[equipmentList\\]\\["+rowIndex+"\\]\\[discountRate\\]").prop("disabled", true);
});
                                                        
var formId = $("form").prop("id");
  
//Set an onchange event handler for the form. When the value of a field changes in the Dynaform, 
//check whether the changed field is the hasDiscount field in the grid. 
//If so, then if hasDiscount is set to "Discount", then enable the discountRate field in the same row. 
//If set to "No Discount", then disable the discountRate field.
$( "#" + formId ).setOnchange( function(fieldId, newVal, oldVal) {
  //check if a field changed inside the grid:
  var aMatches = fieldId.match(/^\[equipmentList\]\[(\d+)\]\[hasDiscount\]$/);

  if (aMatches) {
    var rowNo = aMatches[1];
    
    if (newVal == "Discount") {
      $("#form\\[equipmentList\\]\\["+rowNo+"\\]\\[discountRate\\]").prop("disabled", false);
    }  
    else {   // if (newVal=="No Discount"):
      $("#form\\[equipmentList\\]\\["+rowNo+"\\]\\[discountRate\\]").prop("disabled", true);
      
      //delete the existing value in the discountRate field:
      $("#form\\[equipmentList\\]\\["+rowNo+"\\]\\[discountRate\\]").val("");
      $("#form\\[equipmentList\\]\\["+rowNo+"\\]\\[discountRate_label\\]").val("");
    }    
  }
});
https://www.pmusers.com/index.php/Enable_or_disable_fields_in_grid

Web3 development encompasses creating decentralize[…]

The Upland Clone Script, offered by Dappsfirm, rep[…]

Dappsfirm offers a bet365 clone script that mirror[…]

🚀 Tauchen Sie mit Immediate Alora AI in die Welt d[…]