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
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.