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

Help!! Problem with javascript to lock a PDF form using buttons

Roxi
Registered: Jul 30 2010
Posts: 9

Hi there

I'm new to using javascript so am probably going to asks some pretty stupid questions, but I've got an application form for customers to fill in, and once this is complete I need to have a button at the top giving the option to lock the form.

I've got another form with this feature working, and I copied all the elements of the buttons used in this; however, whilst they work in the original form they do not work in my new form. I've not copied and pasted these (this did not work either) I've re-done them from scratch but copied the details from them.

So I've got the button that stays visible for the user, for which the javascript is:

LockForm();

And then I have a button that is hidden, with:

var btn = this.getField("btnLock");
btn.hidden = true;

var btn2 = this.getField("hideLockButton");
btn2.hidden = true;

this.dirty = false;

Like I said, this is working on the original form but not my new one - any suggestions gratefully received and apologies if I am asking a really stupid question but I just don't know this stuff!

Cheers R

My Product Information:
Acrobat Pro 9.2, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
"Doesn't work" how? Are there any error messages in the console?

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

Roxi
Registered: Jul 30 2010
Posts: 9
Hi there

It doesn't work as in when I test it, it doesn't work - there is meant to be a pop-up box warning that if the user chooses to lock the form now they won't be able to edit it any further - this does not come up.

Is there any reason why this should be so?

Cheers R
Roxi
Registered: Jul 30 2010
Posts: 9
Also, no error messages appear at all.

Cheers R
try67
Expert
Registered: Oct 30 2008
Posts: 2398
In the code you posted there's no mention of any pop-up boxes.
You say you call a method called LockForm. Where is this method defined?
Also, make sure that under Edit - Preferences - JavaScript the option to display the console on errors and warnings is ticked.

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

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
Most likely the script is not executing.

Have you opened Acrobat's JavaScript debugging console, "Ctrl" + "J"?

What is the code for the 'LockFom()' function that you are calling?

George Kaiser

Roxi
Registered: Jul 30 2010
Posts: 9
Hi both

Firstly, thanks for offering to help me, I really appreciate it.

Secondly, I change the preferences as suggested, and when I tried the button now, "Javascript Debugger" popped up with the following:

Acrobat EScript Built-in Functions Version 9.0
Acrobat Annotations / Collaboration Built-in Functions Version 9.0
Acrobat Annotations / Collaboration Built-in Wizard Functions Version 9.0
Acrobat SOAP 9.0

LockForm is not defined
1:Field:Mouse Up

I'm not sure what I should be doing to sort this, as like I said in my original post, this is all copied from a PDF and it works on the original, just not on my new form?!


Cheers R
try67
Expert
Registered: Oct 30 2008
Posts: 2398
The function LockForm is probably defined either as a document-level or a folder-level script.
If it's a doc-level script, you need to copy it into the new file as well.
If it's a folder-level script, then it should still work if you're working on the same computer. If not, you will need to find it and copy it the JavaScripts folder on the other computer.

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

gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4307
There is no action or function named 'LockForm' available to you PDF. There is no Adobe supplied function called 'LockForm', so this would need to be a user or creator written function in JavaScirpt that performs the necessary actions to lock the form fields by making them read only, or applying a signature certificate and locking the form fields, or other actions.

George Kaiser

Roxi
Registered: Jul 30 2010
Posts: 9
Hi there

The script is copied from an old version of the form I am working on - it works on the old one, but I did not work on this, it was supplied by an external company.

The error code I get from the Debugger is:

Acrobat EScript Built-in Functions Version 9.0
Acrobat Annotations / Collaboration Built-in Functions Version 9.0
Acrobat Annotations / Collaboration Built-in Wizard Functions Version 9.0
Acrobat SOAP 9.0

LockForm is not defined
1:Field:Mouse Up
LockForm is not defined
1:Field:Mouse Up
LockForm is not defined
1:Field:Mouse Up
LockForm is not defined
1:Field:Mouse Up


Is there any way to get a lock button on the form, that a user can click on to "lock" the form after editing so no further edits can take place?

Many thanks

R