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

Showing and Hiding SubForms

hb40
Registered: Nov 8 2007
Posts: 4

Hi,

I am very new to Adobe SmartForms, so appologies if I'm making an obvious mistake and asking silly questions :)

I spent about 4 hours trying to figure out how to add/remove subforms (hide and show).

I tried all the scripts that I could find on here and within the Designer help instructions.

here is what I've been doing:

- Create a New form
- Add a button
- Add a subform and rename it Subform2
- Add a text input inside the subform
- Make the parent of the subform flowed
- Make the subform flowed
- Adding the min repeat of subform (initial) to 0 (so it's invisible)
- Leaving the max repeat of the subform blank or set it to 10
- Clicking on the button, going to Script window, ensuring it's Javascript and entering one of the following (tried all of them):

Subform2.instanceManager.addInstance(true);

or

methods.Subform2.instanceManager.setInstances(4);

or other variations i saw around the place and on the forum.

- Switch to Preview mode
- Click the button and... nothing happens :)

Any ideas? where am I going wrong?

Thanks

sconforms
Expert
Registered: Jul 10 2007
Posts: 92
Assuming you're setting the minimum instance count of Subform2 (the one containing the text field) to zero, then the initial state of the form is that Subform2 does [b]not[/b] exist. Since that's the case, you cannot access its Instance Manager via the following syntax:

Subform2.instanceManager.addInstance(0);

because Subform2 doesn't exist. When in the Preview tab, try typing "Ctrl + J". This will show the Acrobat JavaScript Console. When you click on the button, I'll bet you'll see an error to the effect that "Subform2 has no properties".

To get around this, you have to use the alternate method of accessing a subform's Instance Manager object: Every subform has a sibling object which is a reference to its Instance Manager and its name is always the subform's name with an underscore (_) as a prefix. In the case of "Subform2", it's "_Subform2".

In your button's Click event script, change the statement to the following:

_Subform2.addInstance(0);

That should properly create the instance.

If that still doesn't work, then it's possible your form is being previewed as a static PDF form. In that case, see the following article on my blog about ensuring you're previewing in the dynamic PDF format:

[url]http://forms.stefcameron.com/2006/07/24/previewing-as-dynamic-pdf/[/url]

Stefan Cameron obtained his bachelor's degree with Honors in Computer Science at the University of Ottawa and is a Computer Scientist working on Adobe's LiveCycle server products, in particular on LiveCycle Designer ES for the past 5 years.

hb40
Registered: Nov 8 2007
Posts: 4
Hey, many thanks for your reply :)

It turns out what i was doing wrong is having the button outside of the flowed parent form!

So I had:

PageForm
Subform1 (flowed)
Subform2 (repeat)
Button

Where as I needed to have:


PageForm
Subform1 (flowed)
Subform2 (repeat)
Button

The only problem is that the flowed form doesn't allow me to format the location of the button. It's always left aligned and right against the Subform2. What's the way around this? do I create a second positioned subform inside Subform1 with the botton in it?