Add a table row between rows and keep information entered in previous row
Good day,
I posted two questions which were answered by Radzmar below. Thank you! I have received information from the users that there are two issues. (1). When you add a row, the question asks how many rows to add. If you click the cancel button, it still adds a row. It should NOT add a row when the cancel button is clicked. And (2) when you enter the number of rows to add, it adds the rows to the bottom of the table. The rows need to be added below the row of the button pressed. Your help in fixing these errors is appreciated. I tried changing the script but I have not been successful.
var cInput = xfa.host.response("Enter number of rows you want to add:", "Add rows", "1", false),
n = parseInt(cInput, 10) > 0 ? parseInt(cInput, 10) : 1,
i = 0;
for (i; i < n; i += 1) {
_Row1.addInstance(true);
}
To copy data, use a for loop.
Given you have the following structure: Table1.Row1.Date and the Add button is located in the Row1 as well then this script will copy the date fields data to all following rows starting from the current one and where the date field is empty.
if (!Date.isNull) {
var oRows = Table1.resolveNodes('Row1[*]'),
j = this.parent.index,
cDate = Date.rawValue;
for (j; j < oRows.length; j += 1) {
if (oRows.item(j).Date.isNull) {
oRows.item(j).Date.rawValue = cDate;
}
}
}