Skip to main content
Participant
April 13, 2020
Answered

How do I autofill form fields based on user input in the primary form fields?

  • April 13, 2020
  • 2 replies
  • 1706 views

I have a PDF form I am trying to populate information the same way I already got it's matching spreadsheet to do. I just have no idea how to translate that over to the PDF. 

Both the PDF and the .XLSX are atteached. 
Basically the form has 2 columns, Primary and secondary. 

The primary is user input, they put a value in each field in the column. Each line is labeled 1-20 then continues with A-L
The secondary column matches up certain ansers from the primary column and puts them together in each line. The secondary column notes 3-5 primary column fields it needs to grab that info from. 

Example, line 1 has it's primary field, then in the secondary column it notes A,B,C indicating that that field should have the answers from the primary fields of A, B, and C. 

I know nothing about Javascript, but it's become obvious to me that's the only way to do what I want. Would you guys be able to help me with a formula I can plug the appropriate field values into?

This topic has been closed for replies.
Correct answer Thom Parker

Ok, I think I get what you are after. The Secondary fields are named for the fields they pull from. So what you want to do is to concatenate the data entered into Primary's based on the space separated items in the Secondary field name.  That's what I mean by an explanation.

 

Here's how you do it. 

Use a calculation script in the Secondary fields. Since it has to work for every field the script should be document level function, that is generic enough to work for every field.

Here are the steps the script needs to execute:

1) Split current field name into parts using a space as the separator

2) Use these parts to build the primary field names.

3) Acquire primary fields and add them together. 

 

That's it. 

To get started read these articles:

https://www.pdfscripting.com/public/PDF-Form-Scripting.cfm

https://acrobatusers.com/tutorials/splitting-and-rebuilding-strings/

 

2 replies

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
April 14, 2020

Ok, I think I get what you are after. The Secondary fields are named for the fields they pull from. So what you want to do is to concatenate the data entered into Primary's based on the space separated items in the Secondary field name.  That's what I mean by an explanation.

 

Here's how you do it. 

Use a calculation script in the Secondary fields. Since it has to work for every field the script should be document level function, that is generic enough to work for every field.

Here are the steps the script needs to execute:

1) Split current field name into parts using a space as the separator

2) Use these parts to build the primary field names.

3) Acquire primary fields and add them together. 

 

That's it. 

To get started read these articles:

https://www.pdfscripting.com/public/PDF-Form-Scripting.cfm

https://acrobatusers.com/tutorials/splitting-and-rebuilding-strings/

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Thom Parker
Community Expert
Community Expert
April 13, 2020

Yes,this can certainly be done. However, you have a complex process here. To help you we need a simple clear explanation. What are the starting conditions, what does the user do, and what is the result.  

For example, if each line is independent, then explain how the result of a single line is reached. 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Phil101Author
Participant
April 13, 2020

The user fills out each field in the Primary column, 1-20 and A-F
Then each field in the secondary column pulls it's designated 3-5 answers from the primary column and fills that field with those answers. 
In the form, the secondary column notes on the right had side which 3-5 primary column fields it wants to use.