Does anybody know of a script that will allow me to add new Textfield instances that are populated with Data from another Textfield that can also be removed? I've been racking by brains trying to figure out how to do this but whatever instance I create that contains data in it is automatically overwritten with any new instances with data that I create.
Thanks for any help!
Check the data binding for the Textfields..
If you set it to Global, then all the fields with the same name will display the same value. That means if you add fields at runtime, they all carry the same name and so they alldisplay the same value.
But if you do not want to display the same value for the TextField on form and for the newly added TextFields, then you have to set it to either Normal/ None.
In your case, you probably have Global. Change it to Normal/ None.
Thanks for your reply Srini. After searching these boards, however, I discovered that you cannot simultaneously add an instance and populated it at the same time, unless, as you point out, the binding is set to global.
Your assumption might not be coreect.
You can add an instance and still display value in the newly added field at the same time.
If you have a subform "Subform1" and inside the subform you have "TextField1". You want to populate the value of the TextField1 from TextField2.
For Subform1, you set the "Repeat Subform for Each Data Item".
Now you are adding new instance of Subform1 and want to display TextField1 with TextField2 data.
The below code you can place in the click event of button while adding the new Instance.
var intIndex = Subform1.instanceManager.count-1;
//Resolve the Subform1 to the recently added instance and display the value.
xfa.resolveNode("Subform1[" + intIndex + "]").TextField1.rawValue = TextField2.rawValue;
The key here is to resolve the node to the recently added instance.
Hope this gives an idea.
Note: TextField1 and TextField2 both are set to Normal/ None binding in the above example.
Thanks, again, Srini!
You've helped me with half of my problem. I wish to create a "dynamic" list which will allow me to add an instance and populate it at the same time. You've helped me tremendously with this. Now, I wish to find a way to also remove an instance that was added, but not necessarily in the order that it was added.
For example, when adding instances by clicking a button (outside the repeating subform), I create three instances with the following text fields in the order as follows:
Now, I wish to click a button (again, outside the repeating subform) that will allow me to remove instances in the following order:
Unfortunately, everything I've tried until now has only removed the first instance (aaaaaa) or the last instance (cccccc) and usually not in the order I wish them to be removed.
Is there some way to remove specific instances based on the value of the text within the instance rather than on an index value? I think this may be the way to go.
Again, thanks for any help out there. This forum is simply fantastic!