Hi all
I am new to the Adobe arena so I hope that some one can please lead me to accomplish this task.
I have 2 text fields last name & first name
I would like to have it create a third field with the last name, (first character of the first name field) and placing a comma after the last name.
Thank you
James
Hi,
You would place the script in the calculate event of the third field.
This should get you close (you will need to change the object references to suit the names of your objects):
I will use JavaScript:
if (lastName.rawValue !== null && firstName.rawValue !== null) {
this.rawValue = lastName.rawValue + ", " + firstName.rawValue.toString().slice(0,1);
}
You may not need the .toString() bit, but give it a try.
Niall
Hi James,
Yes, it does. LC Designer creates different forms and has different JavaScript syntax. You are in the LC Designer forum and your query may be better answered in an Acrobat forum.
The following script should work in an AcroForm (fingers crossed):
var i = this.getField("firstName");
var j = this.getField("lastName");
var k = this.getField("combinedName");
if (i.value !== null && j.value !== null) {
k.value = j.value + ", " + i.value.toString().slice(0,1);
}
As before, you will need to change the object references to suit your form.
Hope that helps,
Niall
I revised Niall's script some to make it work as a custom calculation script and make it a bit more suitable for an Acroform:
// Get the field values, as strings
var i = this.getField("firstName").valueAsString;
var j = this.getField("lastName").valueAsString;
// Set this field's value if both fields are not blank
// otherwise, set this field to blank
if (i && j) {
event.value = j + ", " + i.slice(0, 1);
} else {
event.value = "";
}
(An acroform field value will never be equal to null.)
The code posted assumes your fields are named "firstName" and"lastName". If your fields are named something else, you'll have to use the exact field names. You can also check for errors in the JavaScript console (Ctrl+j). It is written to be a custom calculate script, so make sure it's in the right place. It will get triggered whenever any field value changes.
North America
Europe, Middle East and Africa
Asia Pacific