Copy link to clipboard
Copied
Help! I tried a lot of various Javascript lines in different ways as actions and custom scripts, but not having much luck...
I am looking to combine the first and last name from earlier 2 earlier fields for a potential applicant, and apply it to a later part of the application. Also if possible, add a comma and then generate the current date as well. If that's too much, I can do that in a seperate field...but would be nice to get it all in one go.
Thanks in advance!
Copy link to clipboard
Copied
To help you out on this issue it would be helpful for you to provide the names of the first and last name fields.
But for the purposes of providing a script I'll assume they are "FirstName" and "LastName".
Place the following script into the custom calculation of the field where the combined name/date will be displayed.
event.value = this.getField("FirstName").value + " " + this.getField("LastName").value + " , " + util.printd("mm/dd/yyyy", new Date());
You can learn more about scripting PDF forms here:
https://www.pdfscripting.com/public/PDF-Form-Scripting.cfm
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
To help you out on this issue it would be helpful for you to provide the names of the first and last name fields.
But for the purposes of providing a script I'll assume they are "FirstName" and "LastName".
Place the following script into the custom calculation of the field where the combined name/date will be displayed.
event.value = this.getField("FirstName").value + " " + this.getField("LastName").value + " , " + util.printd("mm/dd/yyyy", new Date());
You can learn more about scripting PDF forms here:
https://www.pdfscripting.com/public/PDF-Form-Scripting.cfm
Use the Acrobat JavaScript Reference early and often
Copy link to clipboard
Copied
Thanks very much! That worked out perfectly. I was super close, heheh.
Question though: I modded this slightly to get the time added. But is there some way to get that time and date to be precisly when the applicant click on a connected checkbox to make it appear, or perhaps just refresh that triggers the day and time to be refreshed? This is the code in the check box that makes the other field appear, if that helps in any way:
var nDisplay = event.target.isBoxChecked(0) ? display.visible : display.hidden;
this.getField("SigA").display = nDisplay;
Copy link to clipboard
Copied
Never mind on my last question Thom!
I just need to add calculateNow() to the script and done!
Thanks 🙂

