Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Reset button and added rows

kjensen4
Level 4
Level 4

Hello,

I've recently being making a dynamic flowable table with an "add a row" button.  I've also added a reset button to the form and it clears out all the text well, but I was wondering if there was any way for it to reset the rows in the table to 1.  I saw another post that indicated a reset button couldn't do that, but I wasn't not completely clear about that in the post.  Input would be appreciated.  Thanks!

1 Accepted Solution
Steve_L_Walker
Correct answer by
Level 10
Level 10

Looks like you are operating on the wrong table. Try...

// form1.#subform[0].Subform1.Button2::click - (JavaScript, client)

xfa.host.resetData();


var cnt = Subform2.Table.Table1._Row1.count;


for (var i=cnt; i > 1; i--) {

Subform2.Table.Table1._Row1.removeInstance(i-1);

}

rather than...

// form1.#subform[0].Subform1.Button2::click - (JavaScript, client)

xfa.host.resetData();


var cnt = Subform1._detail.count;


for (var i=cnt; i > 1; i--) {

  Subform1._detail.removeInstance(i-1);

}

Steve

View solution in original post

5 Replies
Steve_L_Walker
Level 10
Level 10

The attached contains a dynamic sub-form in which you can add and delete rows. I added a button called 'resetBtn' and add the following script on the click event. It gets the count of row instances, iterates over the sub-form removing row 2..n and then does a resetData() to clear row 1.


// form1.page1.detailHeader.resetBtn::click - (JavaScript, client)


var cnt = form1.page1._detail.count;


for (var i=cnt; i > 1; i--) {

  form1.page1._detail.removeInstance(i-1);

}


xfa.host.resetData();

Steve

kjensen4
Level 4
Level 4

I tried using the script you suggested in the post and the file and it did nothing.  Any other suggestions?  Thanks!

kjensen4
Level 4
Level 4

I'm still hoping to find a way to reset the number of rows in the table on my form when I hit the reset button.  I tried the scripting suggested, but it just isn't working.  I'm including a link to the form if some could give me a clue of what I need to do, I'd appreciate it.  https://acrobat.com/#d=yQV38javGYBkrNdlvcQbKw

Thanks!

Steve_L_Walker
Correct answer by
Level 10
Level 10

Looks like you are operating on the wrong table. Try...

// form1.#subform[0].Subform1.Button2::click - (JavaScript, client)

xfa.host.resetData();


var cnt = Subform2.Table.Table1._Row1.count;


for (var i=cnt; i > 1; i--) {

Subform2.Table.Table1._Row1.removeInstance(i-1);

}

rather than...

// form1.#subform[0].Subform1.Button2::click - (JavaScript, client)

xfa.host.resetData();


var cnt = Subform1._detail.count;


for (var i=cnt; i > 1; i--) {

  Subform1._detail.removeInstance(i-1);

}

Steve

kjensen4
Level 4
Level 4

Thank you so much.  I knew what I had originally been given wasn't correct and I was playing around with the script but I knew I wasn't right.