These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Delete Button - "Are you sure you want to delete?"

jmason
Registered: Jun 22 2007
Posts: 73

Hello, I am using Adobe LiveCycle Designer 8.0 to design a form to keep track of policy/procedure revisions for our financial institution.

I have the basic subform created, with he following fields: Date, Page Numbers, Who sent us feedback, and Comments (the actual field names are more compact). The Comments field expands to fit the text entered.

I added an "Add Revision" button and a "Delete Revision" button at the bottom of the subform, thanks to all the research in my copy of a book titled "Creating Dynamic Forms with Adobe LiveCycle Designer" (a great reference book!) and these forums. The buttons work fine, but I want to add an alert box to the Delete button so that when the user clicks it, a box will pop up asking if they are sure they want to delete the revision, with a Yes and No option. When they click No, it will cancel the request, and when they click Yes, that subform will be deleted. I have looked several places and done several serches and cannot come up with an answer. Please help! Thanks in advance.

My Product Information:
LiveCycle Designer, Windows
Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi jmason,

Have you read this tutorial on Response Dialogs-
http://www.acrobatusers.com/tutorials/2006/popup_windows_part2

There is a link in that tutorial for a PDF to download with examples so you can examine the code used.

Hope this helps,

Dimitri
WindJack Solutions
www.pdfscripting.com
www.windjack.com
jonom
Registered: Jan 31 2008
Posts: 133
Check out xfa.host.messageBox in the help for the different values but the following will work:

form1.#subform[0].Button1::click - (JavaScript, client)

var selection = xfa.host.messageBox("Are you sure you want to delete this revision?", "Confirmation Dialogue", 2, 2);
if (selection == 4) {
// 4 = Yes
// do deletion code;
}
else {
// do nothing;
}
jonom
Registered: Jan 31 2008
Posts: 133
As a followup to Dimitri's link I think the tutorial you want is http://www.acrobatusers.com/tutorials/2006/popup_windows_part1 it covers the subject much better than the help.

The link in the Part 2 tutorial pointing to Part 1 doesn't work.

Where do we submit that kind of errata?
jmason
Registered: Jun 22 2007
Posts: 73
jonom wrote:
Check out xfa.host.messageBox in the help for the different values but the following will work:form1.#subform[0].Button1::click - (JavaScript, client)

var selection = xfa.host.messageBox("Are you sure you want to delete this revision?", "Confirmation Dialogue", 2, 2);
if (selection == 4) {
// 4 = Yes
// do deletion code;
}
else {
// do nothing;
}
Hello jonom,
I entered the following code:
----- form1.Pg1Sub.Rev1_1.Delete::click: - (JavaScript, client) ------------------------------------

this.resolveNode("Rev1_1").instanceManager.removeInstance
(this.parent.index);

var selection = xfa.host.messageBox("Are you sure you want to delete this revision?", "Click Yes or No",2,2);
if (selection == 4){
// 4 = Yes
// do deletion code;
}
else{
//do nothing;
}

It brought up the message box, but whether I clicked Yes or No, the subform was deleted. Not sure where I went wrong. I need to invest some time in learning more about the basics of JS! =) Thanks for your help!
jonom
Registered: Jan 31 2008
Posts: 133
You need to put your deletion code in where I have "// do deletion code". ;)
The // characters are for code comments.

This should do the trick:

var selection = xfa.host.messageBox("Are you sure you want to delete this revision?", "Click Yes or No",2,2);
if (selection == 4){
this.resolveNode("Rev1_1").instanceManager.removeInstance(this.parent.index);
}
else{
// do nothing or you could have something else happen here
}