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

Does script in the Disable Form Fields Tutorial work in Acrobat Pro 9?

lanierbrian
Registered: May 22 2009
Posts: 12
Answered

I understand that there are differences in the Javascript for Acrobat 9, and I am trying to make the script that accompanies Thom Parker's "Disabling (graying-out) Form Fields" tutorial work in a form I have created in Acrobat 9 Pro (and obviously I'm having trouble). In the tutorial, there is different script for Acroform and LiveCycle, and I read his blog regarding changes in the Acrobat 9 Javascript, so I assume that it's not working because of these changes. Could someone enlighten me as to how to modify the script to work in Acrobat 9 Pro?

Although not a programmer, I've followed his directions very carefully, as well as read his blog post regarding how to effectively use copied script (by paying attention to names and values). I have also thoroughly searched this and other forums for an answer to my question, but if it exists here or elsewhere, please forward me to the appropriate post with my apologies!

Thank you in advance for your time and attention!

Brian Lanier

My Product Information:
Acrobat Pro 9.1.1, Windows
nixopax
Registered: Feb 6 2009
Posts: 105
Hi Brian, which part of the script isn't working for you? If you could provide the example of where in the process it's breaking down we can probably help you. Also, it's best to have your console window open to watch for JavaScript errors. To open it, press CTRL+J or go to [u]A[/u]dvanced>[u]D[/u]ocument Processing>[u]J[/u]avaScript Debugger.
lanierbrian
Registered: May 22 2009
Posts: 12
Nixopax,

Thank you for your reply, and good advice! The error I receive from the debugger is that the field I'm trying to enable/disable is not defined.

My form is an evaluation for medical training in which an evaluator records whether or not a medical intervention was performed by the student in a simulated scenario by selecting one of two radio buttons in the first field (did or did not do that particular intervention). If the student performed that item, the evaluator makes a judgment on two qualifying categories, whether that intervention was timely and if it was done correctly. My goal is to disable both of these fields if the evaluator indicates that the intervention was not done. Right now I'm just trying to get one of the qualfiers to disable/enable on one of the interventions, and then to move on to the rest once I'm successful at that.

So, in this example, one button for the PPE_DID field should enable the PPE_TIME field, and one should disable it. The error in the debugger reads the same if I press either button:

PPE_TIME is not defined
1:Field:Mouse Up

I have been careful to make sure that the field names are precise (I've tried carefully typing as well as copy-and-paste). Any advice you can provide will be greatly appreciated!

Brian
nixopax
Registered: Feb 6 2009
Posts: 105
Based on the error message, you aren't calling the field properly.
this.getField('PPE_TIME');
Above would be the correct way to call the field.

However, what you're doing is this:
this.getField(PPE_TIME);
The subtle difference is the lack of quotation marks. Javascript thinks you're referencing a variable named PPE_TIME instead of a field name.

So, just remember, if you're calling the functions, you need to enclose your field name in single or double quotation marks. ' or "

DisableFormField ("PPE_TIME"); EnableFormField("PPE_TIME");
lanierbrian
Registered: May 22 2009
Posts: 12
YES! It works! I was so keen to enter the Field name correctly that I missed the fact that double quotes were used in the tutorial example. For a complete newby to any kind of code, it is extremely gratifying to see it work! Off to the bookstore to buy that book on Javascript...

This solves a real flaw in this evaluation tool that is being used in some important (and wildly underfunded) medical research. Thanks so much for your help!

Brian Lanier
nixopax
Registered: Feb 6 2009
Posts: 105
Before you run off and get a book on JavaScript, make sure you check out the AcroJS Reference. It's free and very indepth. I'm unsure of any Acrobat JavaScript books on the market. The standard books on JavaScript you'll find in stores will no doubt be webpage related JavaScript, which uses the DOM specific to HTML, and will not be cross compatible with Acrobat JavaScript. The best place to learn JavaScript after thoroughly reading the reference would be Thom Parkers PDFScripting.com website. He has multiple examples and easy to integrate snippets of code for everyday form use. Well worth the entrance fee!

http://www.adobe.com/devnet/acrobat/javascript.php
http://www.adobe.com/devnet/acrobat/pdfs/js_api_reference.pdf
http://www.pdfscripting.com
lanierbrian
Registered: May 22 2009
Posts: 12
Will do! Thanks again!
lanierbrian
Registered: May 22 2009
Posts: 12
Nixopax,

Thanks again for your help on this, it works fine both disabling and enabling the fields in question. I was wondering if it is possible to have the fields in the form disabled by default when the form opens? The way it is now, you actually have to check the "NO" button in the first field to disable the next two fields.

Brian