Skip navigation
Currently Being Moderated

repeating subforms

Jul 5, 2012 8:07 AM

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

 
Replies
  • Currently Being Moderated
    Jul 5, 2012 8:52 AM   in reply to NikDK

    Not sure if it's just the way you copy and pasted the code but you are missing the final brace "}" in the second statement.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 5, 2012 9:16 AM   in reply to NikDK

    Hard to say, the code looks ok. It could be how your subforms are structured.

     

    Are the repeating subforms all inside the subfrmRepeatingForm subform?

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 5, 2012 3:16 PM   in reply to NikDK

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 12, 2012 5:43 PM   in reply to NikDK

    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

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points