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

Cancel Next Action

Jeff P.
Registered: Dec 9 2009
Posts: 14
Answered

I have a button with a MouseUp Trigger that performs 2 JavaScript Actions.

Can the first JavaScript Action cancel the execution of the second one if a certain condition is not met?

My Product Information:
Acrobat Pro 9.2, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
No, the actions on a button event are independant of each other. The correct way to do this is to combine the two scripts. Then place the code in the second script into an "if" block that tests some parameter that is set by the first block.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Jeff P.
Registered: Dec 9 2009
Posts: 14
Thank you for your reply.

That makes sense. My second script though is a 'Submit Form', which I didn't actually create, but selected the options Acrobat gave me. How can I submit a form using JavaScript? Need all fields in HTML format.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Read this Article:
http://www.acrobatusers.com/tutorials/2006/submitting_data

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Jeff P.
Registered: Dec 9 2009
Posts: 14
The process fails to navigate to my form. Could you please let me know what I'm missing?

var f = this.getField("Signature");
var f2 = f.value;
var v = f2.substring(0,3);
var myUrl = "http://www.MYSITE123.com/FinalizePDF.aspx";
var myFormat = "HTML";
if (v !== '/s/')
{
app.alert({
cMsg: "Invalid Signature",
cTitle: "Please re-enter the signature.",
nIcon: 0,
nType: 1})
}
ELSE
{
this.submitForm({
cUrl: myURL,
cSubmitAs: myFormat})
};
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The parameter is "cURL". Details are important!

For testing you need to run small sections of the code by themselves. For example just the submitForm line to make sure everything is setup properly. This is what the console window is for.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

try67
Expert
Registered: Oct 30 2008
Posts: 2398
JS is case-sensitive. Use "else" instead of "ELSE".

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

Jeff P.
Registered: Dec 9 2009
Posts: 14
thomp and try67: Thank you for your help.

Here's what works:

var f = this.getField("Signature");
var f2 = f.value;
var v = f2.substring(0,3);
var myUrl = "http://www.MYSITE123XYZ.com/FinalizePDF.aspx";
var myFormat = "HTML";
if (v !== '/s/')
{
app.alert({
cMsg: "Invalid Signature",
cTitle: "Please re-enter the signature.",
nIcon: 0,
nType: 1})
}
else
{
this.submitForm({
cURL: myUrl,
cSubmitAs: myFormat})
};
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Read this article:
http://www.acrobatusers.com/tutorials/2006/submitting_data

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script