Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderators: ArturoRobles, ArturoRobles

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.
Hi all,
I've a strange behavoir with this piece of code (is an example, in production it doesn't show an alert but it set other values for other fields on the same row):
Code: Select all
function modifiedForm(fieldId, newVal, oldVal){
    console.log("fieldId: " + fieldId + " - newVal: " + newVal + " - oldVal: " + oldVal);
    if (oldVal != ''){
        rowID = (fieldId.substring(16,fieldId.length)).substring(0,(fieldId.substring(16,fieldId.length)).indexOf(']'));
        fieldTemp = ((fieldId.substring(16,fieldId.length)).substring(fieldId.substring(16,fieldId.length).indexOf('[')+1));
        field = fieldTemp.substring(0,fieldTemp.length-1);

        if (newVal!=oldVal){
			if (newVal > 500){
				alert("New value>500!");
In brief, it works fine when I make changes but when I remove a row the content of fieldId contain the old index row.
Anyone can help me to understand why and how I can resolve it?!?

I don't understand your question.

Is this what you want to do?
Code: Select all
function modifiedForm(fieldId, newVal, oldVal) {
   //check if changing a particular field in the grid.
   //change myGrid and myField to the IDs of your grid and your grid field.
   var aMatch = fieldId.match(/^\[myGrid\]\[(\d+)\]\[myField\]$/);
   if (aMatch && oldVal != '') {
        var rowNo = aMatch[1];

        if (newVal != oldVal) {
             var newValue = parseInt(newVal);

	     if (newValue > 500) {
		 alert("New value in row "+rowNo+" is over 500. Setting to maximum of 500");
                 $("#myGrid").setValue(500, rowNo, 3); //change 3 to the column number of grid that you want to change
Thanks for your reply,
no, the problem is that if you add more than one row and you exec the code you will have, modifying the 5th row, rowNo=5.
If you delete one row (from 1 to 4) and try to modiy the new 2nd row you have the same rowNo=5 when I'm expecting rowNo=2.
I hope I was clear.
You can try using this:
Code: Select all
var formId = $("form").prop("id");
$("#"+formId).change( function(e) {
  var val =;
  var aMatch = /^form\[clientList\]\[(\d+)\]\[(\w+)\]$/ );
  if (aMatch) {
    var rowNo = aMatch[1];
    var gridFieldId = aMatch[2];
    alert("Field "+gridFieldId+" in row "+rowNo+" was changed to '"+val+"'");
Where "clientList" is the ID of the grid.

I don't know how to get the previous value, but this will get you the row number and ID of the field in the grid.
CRUD and Process

Liliana i want to hear your answer if i say "[…]

Enabling SQL Server in Windows

I’m excited to uncover this page. I need to […]

Hi, Please use query like this: SELECT Forneced.[…]

Casos estão carregando em branco

Boa tarde! Prezados, estou com problemas em algun[…]