My add instance button is working as intended.
The remove instance button is working, but not as I would like it to. The instance it removes is not necessarily the last instance added, as I would like. When "clicked" it removes the second instance listed. This is a problem when you add 5 or so instances, and need to remove the last one, and end up having to remove all of them because removing the #2 instance just messed up the order of instances.
If this is not making sense I can show you what I'm referring to by uploading/sending interested parties the form.
Here is the "click" event javascript code. I adopted the code from the remove instance manager example, maybe I did not convert it correctly to my form. Not sure why it deletes from the first instance down, instead of last instance up. Any help is appreciated.
var nNumSub = 0;
var nSubLength = Subform1.nodes.length;
for (var nCount = 0; nCount < nSubLength; nCount ++) {
if (Subform1.nodes.item(nCount).className == "subform" {
nNumSub = nNumSub + 1;
}
}
nNumSub = nNumSub - 1;
if (nNumSub < 1) {
xfa.host.messageBox("The minimum allowable number of subforms is 1. You cannot remove any more subforms.", "Warning", 3);
}
else {
Subform1.Subform2.SubformImpression.instanceManager.removeInstance(nNumSub);
}
Thank you,
B
Solved! Go to Solution.
Views
Replies
Total Likes
If you want to remove the last one why not use the count method on the instance Manager. This will give you a count of subforms that are displayed (it is 1 based), then subtract 1 to get the instance number for the last subform.
nNumSub = Subform1.Subform2.SubformImpression.instanceManager.count
Paul
Views
Replies
Total Likes
If you want to remove the last one why not use the count method on the instance Manager. This will give you a count of subforms that are displayed (it is 1 based), then subtract 1 to get the instance number for the last subform.
nNumSub = Subform1.Subform2.SubformImpression.instanceManager.count
Paul
Views
Replies
Total Likes
That script does nothing as a replacement script or added to my original script.
It still deletes instances starting at the top.
Perhaps I missed something.
EDIT: Added the -1 to the end of it and worked perfectly when added in parenthesis to my original script.
Thanks again Paul.
Views
Replies
Total Likes
Paul,
So I want to do the same thing, but my instance manager set-up is much simpler:
form1.QuickNoteGathering.Data.Button1::click - (JavaScript, client)
Data.Info.instanceManager.addInstance(1);
So what code would I use to have a button that removes the last instance added?
Also, I want the instances to continue on to several pages if needed (i.e.: my outlay is just a small sample and one can add as many additional information layers as they need). But it all goes awray as it comes to the buttom of the first page. So I can I assure that as you click the add additional info, it will persist to as many pages as needed?
Thanks. I can send you the form if you need me too, since there is no upload anymore to this forum.
thanks
Shai
Views
Replies
Total Likes
Paul has helped me with issue. Here's the code.
Table1.detail.instanceManager.removeInstance(Table1.detail.instanceManager.count -1)
To make your table continues to second page, Make sure your form is Dynamic and set to Flowed.
Views
Replies
Total Likes