Client requested following:
Each click of button creates a new instance of subform ( just 10 text fields), not the table.
They want another button, that will create a new instance of the subform and copy the data from the first instance, every time they click on the button.
Does anyone have a code in JavaScript to share?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
You could probably do this as a loop through the objects in the subform, but given there is only ten, you could script each one in turn:
// Add the instance
page1._Subform.addInstance(true);
// Duplicate from first instance
var nCount = page1._Subform.count - 1;
var oFirst = xfa.resolveNode("page1.Subform[0]");
var oLast = xfa.resolveNode("page1.Subform[" + nCount + "]");
oLast.TextField1.rawValue = oFirst.TextField1.rawValue;
oLast.TextField2.rawValue = oFirst.TextField2.rawValue;
oLast.TextField3.rawValue = oFirst.TextField3.rawValue;
Something like this should work,
Niall
Views
Replies
Total Likes
Hi,
You could probably do this as a loop through the objects in the subform, but given there is only ten, you could script each one in turn:
// Add the instance
page1._Subform.addInstance(true);
// Duplicate from first instance
var nCount = page1._Subform.count - 1;
var oFirst = xfa.resolveNode("page1.Subform[0]");
var oLast = xfa.resolveNode("page1.Subform[" + nCount + "]");
oLast.TextField1.rawValue = oFirst.TextField1.rawValue;
oLast.TextField2.rawValue = oFirst.TextField2.rawValue;
oLast.TextField3.rawValue = oFirst.TextField3.rawValue;
Something like this should work,
Niall
Views
Replies
Total Likes
It worked!!! THANK YOU, THANK YOU NIALL!!!!
Views
Replies
Total Likes
Niall,
What would the script be to duplicate from the previous instance instead of from the first instance? So if you have apples in the first instance, add a row and change to oranges, how would you make sure that the oranges row copied next?
Thanks!
Scott
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies