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

New Here ,
Apr 13, 2020 Apr 13, 2020

Copy link to clipboard

Copied

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?

TOPICS
Acrobat SDK and JavaScript, How to, PDF forms

Views

69

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Apr 13, 2020 Apr 13, 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...

Likes

Translate

Translate
Adobe Community Professional ,
Apr 13, 2020 Apr 13, 2020

Copy link to clipboard

Copied

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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2020 Apr 13, 2020

Copy link to clipboard

Copied

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. 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2020 Apr 13, 2020

Copy link to clipboard

Copied

To give context for what it's used for: 
The worksheet was originally designed by someone playing D&D and games like it to create new pantheons of deities. You fill in the list of domains for all possible dieties in the primary fields, then the combinations in the secondary column inform you what each one's secondary powers are based on their positions in the list.
So in the primary column you would put in all the D&D cleric domains.
Personally I have adapted it to a lot of similar uses, also for RPGs.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Apr 13, 2020 Apr 13, 2020

Copy link to clipboard

Copied

LATEST

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 PDFScripting
Use the Acrobat JavaScript Reference early and often

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines