Copy link to clipboard
Copied
Hi folks,
Newbie here... have two fields in a form: FirstName and LastName. Want to have these show up later as: LastName, FirstName.
For example: "Rick" "Stockstill" would show up later as: "Stockstill, Rick" with a comma separating names and trailing blanks removed.
This is a piece of cake in Excel, but have not figured out how to do same with Acrobat. My first try at a script looks like this:
(Recipient.rawValue=trim(LastName.rawValue)+", "+FirstName.rawValue);
The "Recipient" field is a standard text field that I'm trying to populate using the "Calculate" property. The good news is that I get no error message, but the bad news is that the Recipient field does not get populated.
Any and all assistance greatly appreciated.
Till later,
Rick Stockstill
North East Independent School District
San Antonio, TX
210-407-0317
rstock@neisd.net
OK, in that case you can use this code as the custom calculation script of the Recipient field:
event.value = trim(this.getField("LastName").valueAsString) + ", " + trim(this.getField("FirstName").valueAsString);
function trim(s) {
return s.replace(/^\s+/,"").replace(/\s+$/,"");
}
Copy link to clipboard
Copied
Is this a LiveCycle Designer form or an Acrobat form?
Copy link to clipboard
Copied
Hi again,
Acrobat Form. If the code looks like from LiveCycle, it's because I tried an example from another Forum.
Till later,
Rick S.
Copy link to clipboard
Copied
OK, in that case you can use this code as the custom calculation script of the Recipient field:
event.value = trim(this.getField("LastName").valueAsString) + ", " + trim(this.getField("FirstName").valueAsString);
function trim(s) {
return s.replace(/^\s+/,"").replace(/\s+$/,"");
}
Copy link to clipboard
Copied
Hi again,
Excellent !! Will test and report back shortly.
Much appreciated & till later,
Rick S.
Copy link to clipboard
Copied
Hi again,
That worked perfectly. I'd also like to include the Middle Initial field... but I'll try to do that using your example to learn from... will only ping again if unable to solve.
Very much appreciated & till later,
Rick S.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now