How to Populate an Editable Text Field Based on a Radio Button Selection in PDF
Question details
The user needs a PDF form to automatically insert a specific message into a text field when a third radio button is selected, while keeping the text field editable and leaving it blank for other selections.

- Product
- PDF Editor
- Device & OS
- not provided
- Scenario
- Creating or editing an interactive PDF form with dynamic logic.
- Observed behavior
- The text field must display a default editable message for a specific radio choice and remain blank for all other radio button choices.
Ensure you are using a PDF editor that supports form field creation and custom JavaScript actions. Write down the exact field names for your text field and the export values of your radio buttons before proceeding.
Use a Mouse Up JavaScript Action on the Radio Buttons
Instead of using a calculation script on the text field (which locks the field from user edits), assign a JavaScript action directly to the radio buttons to update the text field value.
Applying a conditional calculation script directly to a text field can overwrite manual user inputs, rendering the field uneditable. To bypass this, we use an action trigger on the radio buttons themselves. This populates the text field when the button is clicked, but still allows the user to manually edit the text afterwards.
Open your PDF document in your PDF editing software and navigate to the Form or Prepare Form tab to reveal all form fields.
Right-click the specific radio button (the third option) that should trigger the message, select 'Properties', and navigate to the 'Actions' tab.
Set the 'Select Trigger' to 'Mouse Up', choose 'Run a JavaScript' from the 'Select Action' dropdown, and click 'Add'.
In the JavaScript editor, input the following code: `this.getField("YourTextFieldName").value = "Your default message";` (replace the field name and message with your actual details), then click OK.
Repeat the process for the other radio buttons in the group, but use this script to clear the field instead: `this.getField("YourTextFieldName").value = "";`.

Easily Create and Edit Interactive PDF Forms with WPS Office
WPS Office provides robust PDF editing capabilities, including the ability to create dynamic forms, add interactive radio buttons, and seamlessly manage text fields.
- 1. Open your PDF: Launch WPS Office and open your PDF document.
- 2. Access form tools: Navigate to the 'Form' tab to access the form creation and editing tools.
- 3. Add interactive fields: Use the 'Radio Button' and 'Text Field' tools to place your elements onto the document.
- 4. Edit field properties: Double-click any placed field to easily configure its name, appearance, and export values.

Frequently Asked Questions
Why can't I edit the text field after using a calculation script?
Calculation scripts run continuously and force the text field to match the script's output, preventing manual overrides. To keep the field editable, you must use an event trigger (like 'Mouse Up') on the radio button to push the value to the text field once, rather than continuously calculating it.
Can I populate multiple text fields from one radio button selection?
Yes. You can add multiple lines of code within the radio button's JavaScript action. Simply add another line like `this.getField("SecondFieldName").value = "Another message";` to update several fields simultaneously.
How do I find the exact name of my form fields?
In form editing mode, double-click the form field or right-click and select 'Properties'. The exact name will be listed under the 'General' tab in the 'Name' text box. Field names are case-sensitive.




