Hello,
I have a form where if the user checks box A, it will open a section with a repeating subform. if the user clicks add, it will add a new instance of the subform. if you then go back and uncheck box A, the repeating subforms should disappear, however they are staying visible.
In the 'change' event of the check box I have the following code:
if(this.rawValue == "1")
{
subfrmRepeatingForm.presence = "visible";
subfrmRepeatingBtn.presence = "visible";
}
if (this.rawValue == "0")
{
subfrmRepeatingForm.presence = "hidden";
subfrmRepeatingBtn.presence = "hidden";
Can anyone offer some help as to why these fields are not clearing?
Thank you in advance,
Nik
Hi,
A couple of suggestions.
If you want to use the change event then you would need to swap out "this.rawValue", with "xfa.event.newText".
With checkboxes I tend to use the click event. When this fires, the users selection has been committed and can be accessed from this.rawValue.
Lastly, a checkbox can be on or off (default), therefore a simpler if/else should cover it:
if (this.rawValue == 1) {
subfrmRepeatingForm.presence = "visible";
subfrmRepeatingBtn.presence = "visible";
}
else {
subfrmRepeatingForm.presence = "hidden";
subfrmRepeatingBtn.presence = "hidden";
}
Hope that helps,
Niall
Thank you for your help Niall. I have moved this script to the click event as suggested however when i uncheck the check box, all instances of the repeating subform still appear. do i need to enter a specific script to have the repeating subforms hide?
Thank you in advance for your help,
Nik
Hi Nik,
Sorry for delay.
You are only referencing one instance of the repeating object (eg the first one). One solution would be to loop through all of the instances of the repeating subform and set the presence of each one in turn. Ther are plenty examples on the forum of xfa.resolveNode()/xfa.resolveNodes() on the forums. Also look here: http://assure.ly/kUP02y.
One other solution would be to put the repeating subforms into a parent flowed subform and then just change the presence of this single subform instead. Single object reference and no looping.
Hope that helps,
Niall
North America
Europe, Middle East and Africa
Asia Pacific