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

Stopping JavaScript

melkker
Registered: Jun 1 2011
Posts: 3

Hi all!
 
I need a solution for my order form issue. I made an automatic order number generator within pdf file with Acrobat. It is combined with two different codes/sections. One is current date and second one is randomly generated 3digit number. My problem is that it generates a new number every time the document is opened.
I want the order number to be generated every time the order form is opened, but It must not change once it has sent to me and I open it.
So is there a way to avoid such thing? I have thought on two solutions :
1. If a client clicks on link to the order, the pdf opens a copy for the client and there is generated number attached, but without the code to generate the number again.
2. When client saves the order it makes the order number permanent for this document or when the document is saved it disables the generation code and the number generated remains.
3. After opening the order form and generating the number for it, it automatically disables the generation code on that document.yet then again I need a copy or some protection not to manipulate original file that sits in the server.
The number must be generated before filling the form, because the form should be used in two ways - online filling and with pen.
Or do you have some better solution for my situation?
 
I'm not really into programming. I firstly saw javascript yesterday, so please as simple as possible :)
Maybe there's a code already written I could use or you could provide me one.
 
Many thanks in advance!
Martin

My Product Information:
Acrobat Pro 9.4.3, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
In the script that sets the numbers add 2 things:
1. A condition that checks if the form field is empty. It will only generate the number (and fill the field) if it's empty.
2. After generating the number you can make the field read-only so the user won't change it by accident.

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

melkker
Registered: Jun 1 2011
Posts: 3
Hello try67!

Thank you for the quick response.
1. This may work. could you please provide me with a suitable code? I really don't know anything about javascript. What I have achieved until now is someway by accident.
2. The fields are already read-only.


try67
Expert
Registered: Oct 30 2008
Posts: 2398
You can use something like this (you will need to adjust the fields' names, of course):

f = this.getField("Text1");
if (f.value=="") { // the field is empty, so let's fill it with something
f.value = "some text";
f.readonly = true;
}

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

melkker
Registered: Jun 1 2011
Posts: 3
This works perfectly! Thank you very much!
All the best to you!