Skip to main content
Participating Frequently
April 6, 2016
Question

Need to map field names to strings

  • April 6, 2016
  • 1 reply
  • 363 views

Hi All,

I have a PDF form with several sections on it. Each section captures information about a person for example Person1 might be a teacher, Person2 might be a student, Person3 might be a parent.

For each of these people the forms captures some information which is common to all of them like Name, Address, Phone, then depending on whether it is a student parent or teacher the are 3-4 other fields which depend on the type of person ie:

PDF FIELD NAMES

Person1 Teacher

TeacherName

TeacherSurname

TeacherAddress

TeacherDOB

TeacherPhone

Teacher ID number

Person2 Student

StudentName

StudentAddress

StudentDOB

StudentPhone

StudentSchool

Person2Parent

ParentName

ParentAddress

ParentDOB

ParentOccupation

ParentPhone

ParentEthnicity

Now a lot of the information for each person can be obtained from another application on the same system so I can copy, for example this information to the clipboard:

CLIPBOARD INFORMATION TO PARSE

Person Id: 1234567

(Name): BUGSY Malone

(Home Address) 123 Any Street

(DOB) 01/01/2000

(Phone) 555-123-4567

(Occupation) Truck Driver

(Race) European

I have written the parser function with regexp to grab this information as store each piece as a string and for the teacher section I have hardcoded

surname

firstname

id

address

ocupation

phone

What I now need is a way to call my parser function from any of the parent, student, or teacher fields, and have the code put the right information in the right place,even though sometimes the field names are slightly different, and sometimes there is not a field for a piece of information from the parser - like "Race"

Thanks in advance,

-Al

George_JohnsonGeckoz100radzmar

This topic has been closed for replies.

1 reply

Inspiring
April 7, 2016

With JavaScript one can determine if a field does not exist.. Just try to get the field object and if it returns a null Ithe field does not exist. If the field exist, then the field object is returned. You can use the JavaScript "typeof" statement to test what a variable is.