Hello all,
I have been looking at the various threads discussing resetting only selected fields in a form and leaving others unchanged.
The form I am working on has a table of 20 body rows with 8 columns. I want to have a reset button that resets 6 of the cells in each row.
I am using the following snippet:
for (var nRow = 1; nRow < 21; nRow++)
for (var nCell = 0; nCell < 6; i++)
{
xfa.host.resetData("form1.page1.wrapper.ICC.Table1.Row[" + nRow + "].rate[" + nCell + "]");
}
This works but is extremely slow (on the order of 10 seconds) and my pc is no slouch. There has to be a simpler (and faster!) way to do this.
I saw one thread where the cells that were to be spared from the reset could be listed but just could not make that work at all. I thought about putting the cells to be spared into a subform but that went nowhere, as I was only able to place individual cells into separate subforms.
Any suggestions will be welcome ... with formcalc script if possible:)
Thanks.
Harry Ohm.
edit: Now it appears it does not work as I first thought. It works on a single row but not when the nested for loops are used.
Message was edited by: HarryOhm
Solved! Go to Solution.
Views
Replies
Total Likes
Hi Harry,
Just two small issues. I would wrap the first for loop in {} and then you have i++ in the second loop:
for (var nRow = 1; nRow < 21; nRow++)
{
for (var nCell = 0; nCell < 6; nCell++)
{
xfa.host.resetData("form1.page1.wrapper.ICC.Table1.Row[" + nRow + "].rate[" + nCell + "]");
}
}
It looks like your table is static (rows do not repeat). One option would be to build up a variable/string with the objects names and then reset that. This is a reset example from one of our forms (http://assure.ly/gBJYj9). Here it is resetting one row and two fields outside of the table:
// reset page 6 only
var f1 = Table1.Row1.description.somExpression + ", ";
var f2 = f1 + Table1.Row1.quantity.somExpression + ", ";
var f3 = f2 + Table1.Row1.unitPrice.somExpression + ", ";
var f4 = f3 + positionedSF.myName.somExpression + ", ";
var f5 = f4 + positionedSF.myAddress.somExpression;
xfa.host.resetData(f5);
Hope that helps,
Niall
Views
Replies
Total Likes
Hi Harry,
Just two small issues. I would wrap the first for loop in {} and then you have i++ in the second loop:
for (var nRow = 1; nRow < 21; nRow++)
{
for (var nCell = 0; nCell < 6; nCell++)
{
xfa.host.resetData("form1.page1.wrapper.ICC.Table1.Row[" + nRow + "].rate[" + nCell + "]");
}
}
It looks like your table is static (rows do not repeat). One option would be to build up a variable/string with the objects names and then reset that. This is a reset example from one of our forms (http://assure.ly/gBJYj9). Here it is resetting one row and two fields outside of the table:
// reset page 6 only
var f1 = Table1.Row1.description.somExpression + ", ";
var f2 = f1 + Table1.Row1.quantity.somExpression + ", ";
var f3 = f2 + Table1.Row1.unitPrice.somExpression + ", ";
var f4 = f3 + positionedSF.myName.somExpression + ", ";
var f5 = f4 + positionedSF.myAddress.somExpression;
xfa.host.resetData(f5);
Hope that helps,
Niall
Views
Replies
Total Likes
Niall,
Many thanks for your reply.
That works much better. Seems to be a liitle speedier.
Harry.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies