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

help with simple javascript to open an html page

SunnyOz
Registered: Feb 8 2008
Posts: 7
Answered

I have been trying for hours to get this to work. I am new to working code on a PDF doc.. and I am sure I am doing something stupid, as I would think this should be a simple task.

I have a form, and I just want to add a javascript to the submit button. (It already is performing a function of creating a pdf of the answers, and eMailing it.)

On the submit button property - action tab - the trigger is 'Mouse UP', and it has the 'Submit a form' action first (to send the eMail). I have then added the action to 'Run a JavaScript'. It then gives me an option of editing the javascript I want to run.

I am used to javascripting in html, but I think this is different in PDF.

Can anyone show me the exact pdf javascript code (to place in the submit button's property box javascript editor) to make a browser window pop-up filled with an html page (http://www.optinest.com/stage/optiuser/2008Conference/PayPal.htm)?

AND if that is possible... can you be so kind to show me the slightly tricker code to check first to see if a specific radio button has been ticked (name="Payment.0", export value="2"), before I open up this pop-up window?

I would greatly appreciate any help, as I need to get this form live this weekend.. and I am failing miserably so far on my own!

Also, can you tell me, if I do get this javascript successfully added to the form, will it function correctly in reader? (I heard there are some accessability issues using javascript in certain reader version.)

Thanks for your help!

My Product Information:
Acrobat Pro 8.0
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You are right, Acrobat JavaScript is 100% complient with Core JavaScript, but the DOM is very, very different. You need the Acrobat JavaScript Reference:

http://www.adobe.com/devnet/acrobat/javascript.php


To open up a browser window use this code

app.launchURL("http://.....");

To check for a a radio button use this code:

if( this.getField("Payment").isBoxChecked(0) )
{
...
}

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

SunnyOz
Registered: Feb 8 2008
Posts: 7
Thank you THOMP for taking the time to answer.. I had just about given up hope of help! The info you provided enabled me to do exactly what I wanted.

Here is what I ended up using:

if( this.getField('Payment.0').value == 2)
{
app.launchURL("http://www.optinest.com/optiuser/2008Conference/PayPal.htm");
}
else
{
app.launchURL("http://www.optinest.com/optiuser/2008Conference/index.htm#payment");
}


Again thanks so much for your help!
SunnyOz