How to Populate a PDF Text Field from a Radio Button Selection
Question details
The user wants to automatically copy or calculate a value into a PDF text field based on the selection made in a radio button group.

- Product
- Device & OS
- not provided
- Scenario
- Creating dynamic PDF forms where text fields update automatically according to user selections on different pages.
- Observed behavior
- The destination text field needs to display the exact export value or a calculated amount derived from the selected radio button.
Ensure you have a PDF editor that supports advanced form field creation and custom JavaScript execution, such as Adobe Acrobat or WPS Office Pro.
Use Custom Calculation JavaScript
Apply a simple JavaScript command in the destination text field to grab the export value of the selected radio button.
This method is highly flexible and works best when you need to pull specific string values or custom numerical amounts from a radio button group directly into a target text field.
Open your PDF form in editing mode, right-click the radio buttons, and select Properties. Under the Options tab, set the Export Value to the desired output (e.g., a specific dollar amount or text string).
Navigate to the page with your destination text field, right-click it, and select Properties.
Go to the Calculate tab, choose 'Custom calculation script', and click the Edit button.
Input the script: event.value = this.getField("RadioButton").value; (ensure you replace 'RadioButton' with the actual name of your radio button group). Click OK and close the properties window to test.

Use Built-In Calculation Features
Utilize standard built-in calculation options if you simply need to transfer or sum the radio button's numerical value without writing code.
Create and Edit Dynamic PDF Forms with WPS Office
WPS Office provides powerful PDF editing tools that allow you to easily create interactive forms, add radio buttons, and configure text fields for data collection without complex scripting.
- 1. Open PDF in WPS: Launch WPS Office and open your PDF document to begin editing.
- 2. Access Form Tools: Navigate to the 'Form' tab located on the top ribbon menu.
- 3. Add Form Fields: Select 'Text Field' or 'Radio Button' to insert them directly into your document layout.
- 4. Edit Properties: Double-click the inserted field to configure its properties, export values, and formatting.

Frequently Asked Questions
Why isn't my text field updating when I select a new radio button?
Ensure that the JavaScript syntax is correct, the field names exactly match (they are case-sensitive), and that JavaScript execution is enabled in your PDF viewer's preferences. Also, check that the destination text field is set to calculate automatically.
Can I pass plain text instead of numbers from a radio button to a text field?
Yes. You can set the Export Value of each radio button to your desired text string. The calculation script will pull that exact text and display it in the destination text field, provided the field is formatted to accept text.
How do I map repeating radio button values to different outputs?
If your radio buttons have repeating export values but you need different specific outputs, you should use a custom JavaScript switch or if/else statement evaluating the exact button selected rather than relying on the overall group's export value.




