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

Auto fill text field only under certain conditions?

marinegq
Registered: Aug 3 2010
Posts: 1

I am brand new to Acrobat 9. I have designed all the forms and everything is in order except for one little bug.

I have 5 rows of text fields that contain LastName, FirstName and DateJoined fields.
I named the DateJoined fields the same to avoid having to reenter the date 5 times. I would like to adjust it so that the DateJoined field from the second row on down gets auto filled ONLY IF any data is entered in the LastName or FirstName fields of the corresponding row.

The way I have it now, if only one person joins on a given date, all 5 DateJoined fields get autofilled. I would like to be able to manually enter the date in the DateJoined field of the first row and the DateJoined fields of the other rows NOT get autofilled with the date from the first DateJoined field UNLESS data is entered in the LastName/FirstName fields of any of rows 2-5. I searched the forums but could not find this same problem. Thanks in advance.

My Product Information:
Acrobat Pro 9.0, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
You have kind of an odd scenario. But the first thing you need to do is to give each of the date fields a different name so that they can be set separately. Now if you want the date on a particular line to be copied when other data on that line is filled out you have two choices.

1. Use an event on one of the other fields to trigger the copy. This event is called only once when the field is filled out.
2. Use the calculate event on the date field to enable the copy. This event is called every time any field on the form is modified.

Without knowing any more about how your form is supposed to work I'd go with #1 for efficiency. So for example, use the Validate event on the first name field like this.

if(event.value != null && event.value != "")
this.getField("DateJoined.Row2").value = this.getField("DateJoined.Row1").value;

The actual field names will need to be adjusted for each row.


Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

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