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

acrobat4 javascript adobe reader7

bradspdf
Registered: Mar 14 2007
Posts: 2

my acrobat4 pdf form has javascript in many of the fields. One field seems to respond properly to the javascript logic when viewed in acrobat4 but not in adobe reader 7.
I have five fields, the first field has form custom script that will update the other four fields. The PltUnit field is not showing when completing the interface in adobe reader 7. Javascript here is in the PltCnt field:
var pn = this.getField("PltCnt.1");
var pu = this.getField("PltUnit.1");
var pc = this.getField("PltChk.1");
var pw = this.getField("PkgWgt.14");
var wu = this.getField("WgtUnit.14");
var tare = 30;
 
if (pn.value < 1) {
pc.display = display.hidden;
wu.display = display.hidden;
pw.value = pn.value * tare + 1;
pu.value = "";
}
else if (pn.value == 1) {
pc.display = display.visible;
wu.display = display.visible;
pw.value = pn.value * tare + 2;
pu.value = "Pallet";
}
else if (pn.value > 1) {
pc.display = display.visible;
wu.display = display.visible;
pw.value = pn.value * tare + 3;
pu.value = "Pallets";
}
pu.display = display.visible;
 
I am doing something similar elsewhere on the form only those fields only impact two other fields, though successfully.
Am I doing something wrong or is there an issue between these versions?
Thanks!

My Product Information:
Acrobat Standard 4.0.5, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Your code seems reasonable with the possible exception of your naming convention. The Dot notation is used in AcroForm JavaScript to distinguish between instances (Widgets) of a field. Are there more than one instance of the "PltUnit" field? or did you name serveral fields "PltUnit.1", "PltUnit.2" etc? You might have confused Acrobat.

So now you need to debug. Start off by looking at what's displayed in the JavaScript Console, are there any error messages?

Get the JS console for Reader here:
[url=http://www.windjack.com/products/freestuff.php]http://www.windjack.com/products/freestuff.php[/url]

Next, place console.println Staments in your code to report the values returned by the "getField" code. Here's an introduction to using the JS Console.

[url=http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/javascript_console/]http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/javascript_console/[/url]

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