Expand my Community achievements bar.

Numbers and instances

Avatar

Level 2

I have made an order form where subforms are added when a button is pushed. Is there anyway to number the subforms as they are generated.  The reason we would like to do this is to keep track of changes to particular line items within the order....

EX.

If i push button A....what i would like to see is...

1.  [Asubform]

7 Replies

Avatar

Level 10

Hi,

Here is an example: https://acrobat.com/#d=tIpEHFadQtSOefZkU9EBfQ

Check out the script in the subform index field.

Hope that helps,

Niall

Avatar

Former Community Member

You can to this by referencing the index of [Asubform], assuming that the textfield is inside [Asubform], like this:

Using Formcalc in the "layout:ready" event on a textfield with a caption:

$.caption.value.#text = Concat($.parent.index + 1, ".  ")

Using Formcalc in the "layout:ready" event on a textfield with no caption:

$.rawValue = Concat($.parent.index +1, ".  ")

Using Javascript in the "layout:ready" event on a textfield with a caption:

this.caption.value.resolveNode("#text").value = this.parent.index +1 + ".  ";

Using Javascript in the "layout:ready" event on a textfield with no caption:

this.rawValue = this.parent.index +1 + ".  ";

Avatar

Level 2

Thanks For the Code! But there is still an issue. I have many buttons that generate different subforms. Say for instance I push on "Button A" and subform 1. "A" appears. Then when I push on "Button B", subform 1. "B" appears. Is there to generate the following:

1. "A"

2. "B"

When I push button B it will recognize A and therefore put a 2 in front of subform B rather than a 1

Avatar

Former Community Member

You need to create multiple instances of the SAME subform in order for the auto-numbering script to work.  It looks like you may have buttons that point to different subforms.

Check your "click" events on all your buttons and make sure they point to the same repeated subform.  Also make sure you check "Repeat Subform for Each Data Item" under the Binding tab of the subform you wish to repeat.

Avatar

Level 10

Hi,

Here is an updated version: https://acrobat.com/#d=tIpEHFadQtSOefZkU9EBfQ

Note that each set of subforms sticks together as new ones are added. You can set up script to move an instance up or down within its set. However I don't think it is possible to shuffle subforms across the two sets.

Hope that helps,

Niall

Avatar

Level 2

Can I email one of you my document? I can't seem to make it work....although both your answers are helpful. Thanks