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

Question about using the setAction method

StevenD
Registered: Oct 6 2006
Posts: 368
Answered

What do I need to do to add the following script to a setAction method.

var nButton = app.alert({
cMsg: "Are you sure you want to clear all of the fields in this form?",
nIcon: 1,
nType: 2,
cTitle: "Confirm Form Reset",
});
if(nButton == 4)
{
resetForm();
}

I am trying to build a batch sequence that will build a reset button programatically on a page. I have added a setAction to a script several times but they have always been short one liners. I have tried several times to remove the returns but nothing has worked so far. I want to add the how thing above so when the button is built the script will be there so when the reset button is pressed the alert opens asking the user if he or she really wants to reset the form.

StevenD

My Product Information:
Acrobat Pro Extended 9.0, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
Here's what it might look like:

var s = "var nButton = app.alert({\rcMsg: \"Are you sure you want to clear all of the fields in this form?\",\rnIcon: 1,\rnType: 2,\rcTitle: \"Confirm Form Reset\",\r});\rif(nButton == 4)\r{\rresetForm();\r}"; getField("Button2").setAction("MouseUp", s);

In short, you need to escape the quotes and can use "\r" for any carriage returns you want to include.

George
StevenD
Registered: Oct 6 2006
Posts: 368
Thanks for the help George. I also discovered after I posted the initial question that I could change the double quotes in the script inside the setAction script to single qoutes and that would work. I didn't know you could escape the quotes.

Anyway it works and I have a nice tidy batch sequence and also a toolbar button that uses a custom dialog to make a single Reset button or a single Print button with a tool tip that prints all page or a whole form or a single Print button that prints just the page the button is on or the option to place both the Print and Reset buttons on the current page.

Thanks for the help.

StevenD