PDF Editing Issues

How to Auto-Fill an Address from a Company Name in a PDF Form

Khadija KhanKhadija Khan Nov 3, 2026 869 views

Question details

The user needs a way to automatically populate an address text field whenever a specific company name is selected or typed into another field within an interactive PDF form.

How to Auto-Fill an Address from a Company Name in a PDF Form
Product
PDF
Device & OS
not provided
Scenario
Creating or editing an interactive PDF form where data entry can be streamlined by linking related fields.
Observed behavior
The address field needs to dynamically update based on a mapping table linked to the company name field using custom scripts.
Before you start

Ensure you have a PDF editing tool that supports custom JavaScript for forms, and compile a complete list of company names and their corresponding addresses before writing the script.

Solution 1Recommended

Add Custom JavaScript to the Form Fields

Use a custom calculation script to map company names to specific addresses so the address field updates automatically.

To achieve automatic population, you can add a simple JavaScript snippet to your PDF form. This script uses an object lookup or a switch statement to match the selected company to its address. When the 'Company Name' field changes, the calculation triggers and updates the 'Address' field accordingly.

1
Prepare the Form Fields

Open your PDF form in edit mode. Ensure you have two distinct fields created: a dropdown or text field named 'CompanyName' and a text field named 'Address'.

2
Open Address Field Properties

Right-click on the 'Address' text field and select 'Properties' from the context menu.

3
Access Custom Calculation

Navigate to the 'Calculate' tab within the Properties window. Select the option for 'Custom calculation script' and click the 'Edit' button.

4
Enter the JavaScript Mapping

Input a script that maps the companies to addresses. For example: var addrMap = {'Acme Corp': '123 Main St', 'Globex': '456 Oak Ave'}; var company = this.getField('CompanyName').value; event.value = addrMap[company] || '';

5
Save and Test

Click 'OK' to save the script, then close the Properties window. Switch to the form preview or viewing mode, and change the Company Name to verify that the Address field populates correctly.

Add Custom JavaScript to the Form Fields
JavaScript Requirement: This method requires the end-user's PDF reader to have JavaScript enabled. If JavaScript is disabled by their security settings, the auto-population will not function.
Efficient PDF Form Management

Create and Edit Interactive PDF Forms with WPS PDF

WPS Office provides a comprehensive set of PDF tools, allowing you to easily create, edit, and manage interactive PDF forms without the complexity of heavy software.

  1. 1. Open your PDF: Launch WPS Office and open your existing PDF document or create a new one from scratch.
  2. 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to reveal interactive field options like Text Field, Check Box, and Combo Box.
  3. 3. Edit Field Properties: Double-click any inserted field to modify its properties, set exact field names, and adjust visual formatting to prepare for data entry.
Easily insert interactive elements like text fields, dropdowns, and checkboxes into your PDFs.Highly compatible with standard PDF forms and properties from Microsoft Office and Adobe Acrobat.Lightweight and fast, offering a smooth editing and data-entry experience.Free and intuitive interface suitable for both beginners and professionals.
microsoft office alternative - wps office

Frequently Asked Questions

Why isn't the address field updating when I change the company name?

Ensure that JavaScript is enabled in your PDF reader's preferences. Additionally, verify that the field names in your JavaScript code perfectly match the actual names of your form fields, as they are case-sensitive.

Can I use a dropdown list for the company names instead of a text field?

Yes, using a dropdown (Combo Box) for the company name is highly recommended. It prevents user typos and ensures the selected value exactly matches the keys in your JavaScript mapping table.

How do I clear the address field if no company is selected?

In your JavaScript mapping, you should include a fallback condition. For instance, using `|| ''` at the end of your value assignment ensures that if the company name is blank or unrecognized, the address field automatically clears out.