Skip to main content
dayna101510
Participant
August 17, 2018
Answered

Using something like the excel LEFT formula in a PDF

  • August 17, 2018
  • 1 reply
  • 782 views

I have a PDF that collects the student's name and birthday. We then take the first three letters of their last name, the first two letters for their first name, and the two digit birth year and create an unique testing ID for each student. This is simple to do in excel with the LEFT formula but I want the fill-able PDF to do this and can't figure out the correct javascript to make it happen. First name, Last name, and birthday are all in separate fields in the PDF currently.

Example:

Last Name: Smith

First Name: Jane

Birthday: 01/03/1980

Desired result in separate field: SMIJA80

Thanks! Dayna

This topic has been closed for replies.
Correct answer try67

Use this code as the custom calculation script of the target field:

event.value = (this.getField("Last Name").valueAsString.substr(0,2) + this.getField("First Name").valueAsString.substr(0,2) +

     this.getField("Birthday").valueAsString.substr(-2)).toUpperCase();

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
August 17, 2018

Use this code as the custom calculation script of the target field:

event.value = (this.getField("Last Name").valueAsString.substr(0,2) + this.getField("First Name").valueAsString.substr(0,2) +

     this.getField("Birthday").valueAsString.substr(-2)).toUpperCase();

dayna101510
Participant
August 17, 2018

Thank you so very much try69! That is exactly what I needed. I really appreciate the help!

try67
Community Expert
Community Expert
August 17, 2018

It's 67, not 69... :-)

And you're welcome!