I have a form i have created with 3 fields:
Customer Name
Customer Number
Account Number
I have two fields that i need to concatenate with CustNum and AcctNu to have an "*" added to the beginning and end of each.
[img]http://lh6.ggpht.com/_Dv3I7BF8ilU/S2mkkBZwv8I/AAAAAAAAAEQ/kEFd1NcSEkM/PDF_CONCAT.jpg[/img]
In Acrobat JavaScript, you use '+' operator for adding number and concatenating strings. But you need to be careful because Acrobat JavaScript makes a guess as to whether it should add or concatenate and frequently makes mistakes in choosing on how to handle each field.
To access a field in Acrobat JavaScript, you need to use 'this.getField("FieldNameStrting")' method and then you can use '.value' or '.vlaueAsString' to obtain the value of field or the string value entered into the field.
There is a special object called the 'event', which is the current field that Acrobat/Reader is focused on and there are a number of properties and methods for this object. '.value' is one of the properties.
So you could use for your custom calculation script:
event.value = '*' + this.getField("CUSTOMER').valueAsString + '*';
A more generalized solution could be created using the 'function' statement.
George Kaiser