Skip navigation
Currently Being Moderated

add instance and hidden fields

Apr 18, 2012 8:10 AM

I have a section in my form where you can add multiple subforms by clicking a button. i also have a field within the subform that only appears when one of 4 radio buttons is checked. if the radio button is checked then the user adds multiple subforms by clicking the button, the hidden fields appear as they are suppose to. If the user then changes their selection and chooses another radio button, it should remove the fields on each instance. the problem is that if it is only removing fields from the first and last instance, but nothing in between.

 

Under the change event of the radio buttons I have used the following (for radio buttons 1, 3 and 4)

when these buttons are clicked i want Text1 & Text2 to hide on all instances.

 

var intNewIndex = form1.subfrm1.instanceManager.count-1;

 

form1.resolveNode("subfrm1[" + intNewIndex + "]").Text1.presence = "hidden";

 

form1.resolveNode("subfrm1[" + intNewIndex + "]").Text2.presence = "hidden";

 

 

and for radio button 2 i have the following under the change event:

for Radio button 2 i want Text1 and Text2 to appear on all instances.

 

var intNewIndex = form1.subfrm1.instanceManager.count-1;

 

 

 

form1.resolveNode("subfrm1[" + intNewIndex + "]").Text1.presence = "visible";

form1.resolveNode("subfrm1[" + intNewIndex + "]").Text2.presence = "visible";

 


Thanks in advance for your help,


Nik

 

 

 
Replies
  • Currently Being Moderated
    Apr 18, 2012 9:41 AM   in reply to NikDK

    Hi Nik,

     

    If using JavaScript you will need a loop to go through all of the instances, changing the presence of the objects in each instance in turn. There is an example of looping though repeating objects using both xfa.resolveNode() and xfa.resolveNodes(). http://assure.ly/kUP02y.

     

    If using FormCalc, then you could use the wildcard to access all instances:

     

    subfrm1[*].Text1.presence = "hidden" 
    subfrm1[*].Text2.presence = "hidden"
    

     

    The wildcard doesn't work in JavaScript, because the compiler interprets [] as an array.

     

    Hope that helps,

     

    Niall

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 18, 2012 10:50 AM   in reply to NikDK

    Hi Nik,

     

    Can you share your form? If so, then upload it to a file sharing site (like Acrobat.com); publish it and then post the published link here.

     

    Niall

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 18, 2012 1:36 PM   in reply to NikDK

    Contact me via http://www.assuredynamics.com and I will have a look when I can.

     

    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