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

Autofill: Contents of two fields merged into a third

thesilverliner
Registered: Mar 10 2009
Posts: 5
Answered

Hi everyone. I am new here, and I think I am going crazy. I'm trying to do something that should be simple, but everything I've googled and tried has come up fruitless.

I need to have two fields auto propagate into a third separated by a hyphen.

For example, end user fills in form field one with "Name", form field two with "Occupation", I need the third form field to display "Name-Occupation". This should be simple, no?

I'm a bit new to javascript. This is what I wrote under custom format script:

var name;
name=this.getField("Name");
var occupation;
occupation=this.getField("Occupation");

document.write(name);
document.write="-";
document.write(occupation);

What am I doing wrong? I'm on a bit of a deadline, this has to be completed tomorrow. Any advice is much appreciated. Thanks!

My Product Information:
Acrobat Pro 8.0, Macintosh
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
First Acrobat JavaScript is not the same as web JavaScript, there is no 'dowument.write' method. Both JavaScripts are Object Oreintated languages, so you need to indentify an object and then access a property (value) or use a method associated with that object.

You can use the following "Custom calculation script" to concatinate two fields:
// get the value of the two fields to be joinedvar name = this.getField("Name").value;var occupation = this.getField("Occupation").value;// fillin field with name and occupationevent.value = name + '-' + occupation;

You might want to add additional code for either or both fields are empty.

See [url=http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=18439]Combine into 1?[/url] for a more generalized solution that includes code for handling missing data.

George Kaiser

thesilverliner
Registered: Mar 10 2009
Posts: 5
Thanks so much George! That worked wonderfully.