Copy link to clipboard
Copied
Hello,
I'm trying to make multiple buttons that when hit will pull the fields above It down until it hits the field where the button lies:
Once all the fields move down then the value of the fields that are next to the button pressed will be changed to "".
I have tried to use the following code but it does not seem to work:
var idNumber = parseInt(event.target.name.replace("Add", ""));
for (var i = 40; i >= idNumber; i--) {
this.getField("ID" + i).value = this.getField("ID" + (i - 1)).value;
this.getField("Desc" + i).value = this.getField("Desc" + (i - 1)).value;
this.getField("No" + i).value = this.getField("No" + (i - 1)).value;
this.getField("Unit" + i).value = this.getField("Unit" + (i - 1)).value;
this.getField("Price" + i).value = this.getField("Price" + (i - 1)).value;
this.getField("Total" + i).value = this.getField("Total" + (i - 1)).value;
}
this.getField("ID" + idNumber).value = "";
this.getField("Desc" + idNumber).value = "";
this.getField("No" + idNumber).value = "";
this.getField("Unit" + idNumber).value = "";
this.getField("Price" + idNumber).value = "";
this.getField("Total" + idNumber).value ="";
This code just replicates the first field that has a value to the fields under it one time.
Can someone please help me with this problem?
Thank you.
Copy link to clipboard
Copied
I have successfully made this code which does what I have described. I was advised not to use "=>" but it seems to be the only way the script works );
var idNumber = parseInt(event.target.name.replace("Add", ""));
for( i = 40; i => idNumber; i-- ){
this.getField("ID" + i).value = this.getField("ID" + (i - 1)).value;
this.getField("Desc" + i).value = this.getField("Desc" + (i - 1)).value;
this.getField("No" + i).value = this.getField("No" + (i - 1)).value;
this.getField("Unit" + i).value = this.getField("Unit" + (i - 1)).value;
this.getField("Price" + i).value = this.getField("Price" + (i - 1)).value;
this.getField("Total" + i).value = this.getField("Total" + (i - 1)).value;
if (i === idNumber+1) { break; }
}
this.getField("ID" + idNumber).value = "";
this.getField("Desc" + idNumber).value = "";
this.getField("No" + idNumber).value = "";
this.getField("Unit" + idNumber).value = "";
this.getField("Price" + idNumber).value = "";
this.getField("Total" + idNumber).value = "";
Copy link to clipboard
Copied
Empty column or empty row?
Copy link to clipboard
Copied
Row* sorry
Copy link to clipboard
Copied
Can you share the form?
Copy link to clipboard
Copied
Thank you for your help!
Copy link to clipboard
Copied
Use following to clear the row:
var i = idNumber;
this.getField("ID" + i).value = "";
this.getField("Desc" + i).value = "";
this.getField("No" + i).value = "";
this.getField("Unit" + i).value = "";
this.getField("Price" + i).value = "";
this.getField("Total" + i).value = "";
Copy link to clipboard
Copied
@Bernd Alheit
Thank you, but this still does not fix the issue. );
It still stops at the first field row that has a value.
Copy link to clipboard
Copied
Check the Javascript console for errors.
Copy link to clipboard
Copied
@Bernd Alheit
No errors showing. );
Copy link to clipboard
Copied
Your script varies from row to row.
You can put the script in a function and use the function at the rows.
Copy link to clipboard
Copied
Sorry, @Bernd Alheit I do not understand? how does the script vary? (besides the row number "idNumber").
Copy link to clipboard
Copied
I have successfully made this code which does what I have described. I was advised not to use "=>" but it seems to be the only way the script works );
var idNumber = parseInt(event.target.name.replace("Add", ""));
for( i = 40; i => idNumber; i-- ){
this.getField("ID" + i).value = this.getField("ID" + (i - 1)).value;
this.getField("Desc" + i).value = this.getField("Desc" + (i - 1)).value;
this.getField("No" + i).value = this.getField("No" + (i - 1)).value;
this.getField("Unit" + i).value = this.getField("Unit" + (i - 1)).value;
this.getField("Price" + i).value = this.getField("Price" + (i - 1)).value;
this.getField("Total" + i).value = this.getField("Total" + (i - 1)).value;
if (i === idNumber+1) { break; }
}
this.getField("ID" + idNumber).value = "";
this.getField("Desc" + idNumber).value = "";
this.getField("No" + idNumber).value = "";
this.getField("Unit" + idNumber).value = "";
this.getField("Price" + idNumber).value = "";
this.getField("Total" + idNumber).value = "";
Copy link to clipboard
Copied
You doesn't use the same script at all buttons.
Copy link to clipboard
Copied
I had changed all the buttons, and it still didn't work
Copy link to clipboard
Copied
Use a function then you need change the script only once.

