Expand my Community achievements bar.

add instance and hidden fields

Avatar

Former Community Member

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

 

6 Replies

Avatar

Level 10

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

Avatar

Former Community Member

Hi Niall, thank you for your help. I have looked at the link you provided however I am not a programmer by trade, therfore some of this is confusing to me. Are you able to show me an example of how it should be written if its not too much trouble?


Thanks again,

Nik

Avatar

Level 10

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

Avatar

Former Community Member

i dont mind sending it to you, but it cant be posted for the public to see. is this still possible?

Avatar

Level 10

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

Niall