Expand my Community achievements bar.

SOLVED

2 table rows - one "Add Row" button

Avatar

Level 4

I am a novice, not alot of training with javascript.

I need 2 table rows added to a table without having multiple "add row" buttons. I would like to be able to add both rows with one button.

right now the button is set for the most current row:

Table1._Week.addInstance(0);

the row above is Table1._Codes

How do I script this in order to have both rows appear when the Add Row button is selected?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Here is the form back to you: https://acrobat.com/#d=HWL3d8qeEmz6Tyn8agXz5Q

You may want to check the fonts, as I did not have them on my system.

In any case here is what I did:

  1. Grouped the two rows into one section (because you want to keep them together) and set this section to be the repeating elements (eg turned off repeating for Weeks and Codes).
  2. Set Table1 to allow content to break across pages.

Hope that helps,

Niall

View solution in original post

7 Replies

Avatar

Level 10

Hi,

A couple of things without benefit of seeing the form.

Are the repeating rows called:

'Week' / 'Codes'?

OR

'_Week' / '_Codes'?

The underscore '_' is shorthand for instanceManager, which is used to call the addInstance. If I assure that the repeating rows are just 'Week' / 'Codes' then the following javascript in the click event of the button should work:

Table1._Week.addInstance(true);

Table1._Codes.addinstance(true);

This should add a row to each repeating row in one button.

Please note that the parameter for the addInstance is either 0 (false) or 1 (true), which relates to whether the row will be data merged with the form.

Hope that helps,

Niall

hmmm, see you have another thread on this: add multiple rows with add a row button ???

Avatar

Level 4

Also, make sure you have the rows set to repeat because you may think your scripts aren't working when it's really a form field setting that isn't correct.

Avatar

Level 4

Thanks Niall

It is working, but is not working - it works in the sense that it is adding the additonal row but it is in the wrong place. Is there somewhere for me to post to this form.

Avatar

Level 10

Hi,

Yes, if you upload your form onto Acrobat.com and then share the published link/URL here.

Niall

Avatar

Level 4

https://acrobat.com/#d=WLkWyjnHze0dV6-Jqy31cw

The dilemma is that I would all of the both rows to remain together -

when the add row button is clicked the bottom row doesn't remain with the first instance.

Avatar

Correct answer by
Level 10

Hi,

Here is the form back to you: https://acrobat.com/#d=HWL3d8qeEmz6Tyn8agXz5Q

You may want to check the fonts, as I did not have them on my system.

In any case here is what I did:

  1. Grouped the two rows into one section (because you want to keep them together) and set this section to be the repeating elements (eg turned off repeating for Weeks and Codes).
  2. Set Table1 to allow content to break across pages.

Hope that helps,

Niall

Avatar

Level 4

Thanks Niall!

You are a lifesaver!!