PDF In-Depth

Fields That Trigger Fields - The watch() method

July 20, 2001

Advertisement
Advertisement
 

On one of the discussion boards, somebody posted a request asking how a user selection in a combo box could be made to alter a global, and then all the other fields in the form would adjust their values based on the value in the global. This would ordinarily be a problem that you could solve quite easily with JavaScript's built-in watch() method, which every object inherits from the generic Object object. The watch() method allows you to assign a callback function (of your own design) to any property of any object, so that whenever any instruction or event causes the property in question to be altered, your callback is called automagically.

There's only one problem. The watch() method, although present in Acrobat JavaScript, doesn't work correctly (at least under Acrobat 4.05 for Mac). It causes the property that's being "watched" to become undefined. Also, the oldval argument to the callback function doesn't contain anything after that, for obvious reasons. (The callback always gets three parameters, called id, oldval, and newval. See any good JavaScript book for details.) So far, I haven't found any workaround. This is apparently another one of those things that will (maybe) be fixed in the next major upgrade of Acrobat.

If anybody out there has found a way to make the watch() method work correctly, I'd be grateful to see a PDF form with code that shows it working. Post it to the Planet PDF Forum at http://forum.planetpdf.com/

Noteworthy JavaScript Book

From time to time people ask me if I know of any really good JavaScript books. I usually recommend David Flanagan's JavaScript, the Definitive Guide for a heavyduty reference (it's outstanding) or Negrino and Smith's Visual QuickStart book on JavaScript for an easy beginner-level introduction. Now I've added a third book to the list, which I can recommend to anyone who needs (how shall I say?) a broader overview of the scope and possible uses of JavaScript. Nigel McFarlane's Instant JavaScript (Wrox) includes discussions of server-side JavaScript, security issues, connection points with Java, and (in one nicely done chapter) troubleshooting and debugging. McFarlane is one of few authors who distinguishes properly between core JavaScript, ECMAscript, browser extensions, and server extensions. On the down side, the book's index is weak; the methods of the built-in objects (Array, Date, Math) are not discussed adequately (for this, you'll still need Flanagan); and there is no mention of PDF per se. (But then again, no book out there mentions PDF JavaScript.) However, the reference sections in the back of the book are noteworthy, the writing style is terse without being dry, and for $24.95 list ($19.99 if you order online), it's not going to break anyone's budget. I wouldn't necessarily recommend it as your first or only book on JavaScript. But as a second or third book, it's good, because it will take your knowledge a step beyond where all the other JavaScript books bring leave you off. You'll get a well-rounded look at the language and what it is capable of in a variety of environments.

Related Products at PDF Store

Nitro PDF Professional

Nitro PDF Professional, your PDF creation and editing product. Priced at $99, Nitro PDF Pro is the m... View full product details
Download free demo

XpdfViewer

This ActiveX control (OCX) provides a PDF file viewer component, enabling developers to add PDF view... View full product details
Download free demo

Adobe? Acrobat? & PDF Software

The No.1 PDF and Acrobat software store for tools to create, edit and publish PDF files. Get Nitro P... View full product details
Download free demo

PDF In-Depth Free Product Trials Ubiquitous PDF

Nitro PDF Professional

the perfect PDF product for business and enterprise, combining an extremely competitive price with a...

Download free demo

XpdfViewer

This ActiveX control (OCX) provides a PDF file viewer component, enabling developers to add PDF viewing...

Download free demo

Ubiquitous PDF: PDF eBooks-Library

If you are looking for a good store of PDF content, you could do a lot worse than visiting eBooks-Library.com...

September 03, 2009
Search Planet PDF
more searching options...







Download PDF Creator

Download The Best of Planet PDF volume 2
Planet PDF Newsletter
Most Popluar Articles
Features

Collating PDFs using JavaScript

Despite the numerous benefits, there can be potential issues with the conversion of paper documents into electronic archives. When scanning paper pages into PDF, it's possible to end up with the odd- and even-numbered pages in separate PDF files. It can be very time-consuming to collate them manually, but there is an easier way. Sean Stewart explains.

Featured Product

BCL easyPDF SDK

BCL easyPDF SDK is a set of PDF Programming Libraries designed specifically to help Software Developers / Programmers build and deploy enterprise class PDF applications for corporate wide PDF...

Platinum Sponsor
Create & Edit PDF - Nitro PDF Software

ARTS PDF

Silver Sponsors

PDF-Tools enfocus

QuickPDF: The Unrivaled PDF Developer Toolkit