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
BedrockMission!

Learn More

View all

Sign in to view all badges

Delete rows from an expanding table

Avatar

Avatar
Validate 10
Level 3
Geckoz100
Level 3

Likes

20 likes

Total Posts

143 posts

Correct Reply

3 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 10
View profile

Avatar
Validate 10
Level 3
Geckoz100
Level 3

Likes

20 likes

Total Posts

143 posts

Correct Reply

3 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 10
View profile
Geckoz100
Level 3

13-10-2015

Hello,

I have an expanding table that allows users to click a "+" button in the row to add more rows.  The table contains required fields.  There is a radio button in another part of the form that if set to "No", the whole section containing the table is hidden.  I need to delete any extra rows the user may have added to the table before selecting that "No" answer, leaving only the first three rows (2 title rows and the first data row).  So if the table had six names entered (total of 8 rows) I want it to delete 7 rows; I remove the value from the first row separately.  I tried something like this, but I couldn't make it work; I'm not a very experienced scripter.  Thanks.


for (var oLen = Table1.nodes.length; oLen>3; t++) {

Table1.parent.parent.instanceManager.removeInstance(oLen);

}



Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Springboard
MVP
Magus069
MVP

Likes

143 likes

Total Posts

1,078 posts

Correct Reply

155 solutions
Top badges earned
Springboard
Validate 1
Ignite 3
Ignite 1
Establish
View profile

Avatar
Springboard
MVP
Magus069
MVP

Likes

143 likes

Total Posts

1,078 posts

Correct Reply

155 solutions
Top badges earned
Springboard
Validate 1
Ignite 3
Ignite 1
Establish
View profile
Magus069
MVP

13-10-2015

Hi there,

There is an error in your for statement.

You are starting at the last instance of the row and you want to delete any rows starting from the last down to the 3rd row...

You must change your value when you are deleting 1 row, but instead of changing the oLen value you are changing the variable "t"

Also if you are starting at the last instance, and going down to the third row, you will want to decrease the index you are using instead of increasing it...

So you're code need some minor changes, and it should look like this:

Hope this help!

Answers (1)

Answers (1)

Avatar

Avatar
Validate 10
Level 3
Geckoz100
Level 3

Likes

20 likes

Total Posts

143 posts

Correct Reply

3 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 10
View profile

Avatar
Validate 10
Level 3
Geckoz100
Level 3

Likes

20 likes

Total Posts

143 posts

Correct Reply

3 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 10
View profile
Geckoz100
Level 3

16-10-2015

That did the trick, thanks!  (of course, I hadn't noticed that I forgot to change the "t" for my own counter)