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

Remove Row button with alert

Avatar

Avatar
Validate 1
Level 1
1300virginia
Level 1

Like

1 like

Total Posts

24 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
1300virginia
Level 1

Like

1 like

Total Posts

24 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
1300virginia
Level 1

18-02-2015

Hello,

I have a table that can add and remove rows dynamically. An alert needs to be added to the remove button which I have done.  The alert works but when you select OK on the alert the row is not removed.

Would this be the correct way to accomplish this task?

I am not a programmer and now wondering if my code edit is wrong or there is an alternate solution.

Thank you

Capture.PNG

This is the code I have for the remove button.

form1.FSE_1.Pre_EX.Buttons.Remove::click - (JavaScript, both)

var cMsg = "Continuing with the current action will remove all cell entries for this row";

cMsg += "\n\nDo you want to continue?";

var nRtn = app.alert(cMsg,1,1,"Question Alert Box");

if(nRtn == 4)

{if (Table1._Item.count > 1)

Table1._Item.removeInstance(Table1._Item.count - 1);

console.println("The Response Was Yes");

}

else if(nRtn == 3)

{ // No Response

  console.println("The Response Was No");

}

else  

{ //Unknown Response

  console.println("The Response Was somthing other than Yes/No: " + nRtn);

}

----------------------------------------------------------------------------------------------------------------------------

This is the code I have for the Remove button before adding the alert which worked.

form1.FSE_1.Day_1.Buttons.Remove::click - (JavaScript, both)

if (Table1._Item.count > 1)

  Table1._Item.removeInstance(Table1._Item.count - 1);

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Springboard
MVP
Magus069
MVP

Likes

143 likes

Total Posts

1,072 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,072 posts

Correct Reply

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

18-02-2015

The way I understand how it works right now is you are removing the last row of the table.. If you want to remove the row where the remove button is, you should be removing the instance itself with its index...

instead of using the following line

you should have something like this

Hope this help!

Answers (6)

Answers (6)

Avatar

Avatar
Validate 1
Level 1
1300virginia
Level 1

Like

1 like

Total Posts

24 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
1300virginia
Level 1

Like

1 like

Total Posts

24 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
1300virginia
Level 1

19-02-2015

Thanks again.

Avatar

Avatar
Springboard
MVP
Magus069
MVP

Likes

143 likes

Total Posts

1,072 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,072 posts

Correct Reply

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

18-02-2015

Hi there,

I am sorry, I thought you would have the add and remove row inside the row ...

I am a bit confused why it is not working... So your original code should be working using the (Table1._Item.count - 1)

Avatar

Avatar
Validate 1
Level 1
1300virginia
Level 1

Like

1 like

Total Posts

24 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
1300virginia
Level 1

Like

1 like

Total Posts

24 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
1300virginia
Level 1

18-02-2015

Thank you for all of your help.

Avatar

Avatar
Validate 1
Level 1
1300virginia
Level 1

Like

1 like

Total Posts

24 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
1300virginia
Level 1

Like

1 like

Total Posts

24 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
1300virginia
Level 1

18-02-2015

Thanks for all of your help.

I'm sorry but I don't think I am following you a 100% as I've added row1 and buttons per your last post but it is not working.

var cMsg = "Continuing with the current action will remove all cell entries for this row";

cMsg += "\n\nDo you want to continue?";

var nRtn = app.alert(cMsg,1,1,"Question Alert Box");

if (nRtn == 1) {

// OK Response

if ( Table1._Item.count > 1 ) {

Table1._Item.removeInstance(this.row1.buttons.index);

console.println("The Response Was " + nRtn + ". (1 is OK.)");

}

} else if ( nRtn == 2 ) {

// Cancel Response

console.println("The Response Was " + nRtn + ". (2 is Cancel.)");

} else {

//Unknown Response

console.println("The Response Was somthing other than Yes/No: " + nRtn);

}

The screen shot below shows how I have the table set up. 


The first gray row cell in the table has the following:

form1.FSE_1.Row1.Table1.Item.ItemIndex::calculate - (JavaScript, both)

(this.parent.index + 1) + "PRE";

The Add button has:
Table1._Item.addInstance(0);

The original remove button has:

if (Table1._Item.count > 1)

  Table1._Item.removeInstance(Table1._Item.count - 1);

Capture111.PNG

Avatar

Avatar
Validate 1
Level 1
1300virginia
Level 1

Like

1 like

Total Posts

24 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
1300virginia
Level 1

Like

1 like

Total Posts

24 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
1300virginia
Level 1

18-02-2015

Thank you very much and now understand the 1, 2, 3, and 4 or have an understanding.

I did more checking and tried the following but it is still not removing the added row.  I don't know that much about this but it should be working now.

form1.FSE_1.Pre_EX.Buttons.Remove::click - (JavaScript, both)

var cMsg = "Continuing with the current action will remove all cell entries for this row";

cMsg += "\n\nDo you want to continue?";


var nRtn = app.alert(cMsg,1,1,"Question Alert Box");


if (nRtn == 1) {

if ( Table1._Item.count > 1 ) {

// OK Response

Table1._Item.removeInstance(Table1._Item.count - 1);

console.println("The Response Was Yes");

} else if ( nRtn == 2 ) {

// Cancel Response

console.println("The Response Was No");

} else {

//Unknown Response

console.println("The Response Was somthing other than Yes/No: " + nRtn);

}

}

Avatar

Avatar
Springboard
MVP
Magus069
MVP

Likes

143 likes

Total Posts

1,072 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,072 posts

Correct Reply

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

18-02-2015

Hi there,

you got it almost right... if your variable nRtn is 4, that means the user answered 'yes' but you give the options for 'ok' and 'cancel'

  • 1 (OK)
  • 2 (Cancel)
  • 3 (No)
  • 4 (Yes)

So if u are using 'ok' and 'cancel', the value can only be 1 or 2

Hope this help!