These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Nesting "if" statements

AJP256
Registered: Jun 19 2009
Posts: 2

I'm trying to use a radio button to control a repeating subform and the subform containing it. When the value for the radio button is "no", the containing subform is hidden, but the repeating subform contained within it isn't altered (so in case someone makes a mistake they don't lose all of their data). When the radio button value is "yes", the containing subform is rendered visible, and I'd like to have it add an instance of the repeating subform only if there are no instances of it currently. Unfortunately, I can't get the second part to work, and for various reasons I can't use the Initial Count or Minimum Count properties in the Bindings tab. Here's the code I'm using (in the "change" event of the radio button group):

if (this.rawValue=='1'){

Container_Subform.presence="visible";

if (Container_Subform.Repeating_Subform.instanceManager.count=='0')

Container_Subform._Repeating_Subform.addInstance(1);

xfa.form.recalculate(1);

}

I'm thinking it must be something simple, but I can't think of it. Thanks in advance for your help.

My Product Information:
LiveCycle Designer, Windows
suewhitehead
Registered: Jun 3 2008
Posts: 232
I think you need to add some brackets. An example from "Beginning Javascript" is this:
if (degCent < 100)
{
If(degCent >0)
{
document.write("degCent is between 0 and 100");
}}

So I think it would either be this:

if (this.rawValue=='1'){

Container_Subform.presence="visible";

if (Container_Subform.Repeating_Subform.instanceManager.count=='0'){

Container_Subform._Repeating_Subform.addInstance(1);

xfa.form.recalculate(1);

}
}

or this:

if (this.rawValue=='1'){

Container_Subform.presence="visible";}

if (Container_Subform.Repeating_Subform.instanceManager.count=='0'){

Container_Subform._Repeating_Subform.addInstance(1);

xfa.form.recalculate(1);}
scderacjor
Registered: Mar 27 2009
Posts: 123
Sometimes it depends on the subforms being flowed and positioned. The subform containing all of that must be flowed, while the instance that would appear with the radio button must be positioned. This way, when the instance occurs, the big box can expand. I'm not sure why the instance subform must be positioned, but if you do have a dynamic element within it (like a text box) you can check the expand to fit for height, and make sure the subform (positioned/instance one) is set to expand to fit height as well. With that, you should be able to set the Initial/Minimum/Maximum count.