PDF Editing Issues

How to Populate and Lock PDF Fields Based on Radio Button Selection

Aamir Naveed AkramAamir Naveed Akram Nov 3, 2026 869 views

Question details

The user wants to conditionally populate text fields with 'N/A' and make them read-only when a specific radio button is selected in a PDF form, while keeping them blank and editable for other choices.

How to Populate and Lock PDF Fields Based on Radio Button Selection
Product
PDF Editor
Device & OS
not provided
Scenario
Creating an interactive PDF form that requires conditional logic to lock and auto-fill specific text fields based on user input.
Observed behavior
The text fields need to dynamically change their value and read-only status depending on the active state of a radio button group.
Before you start

Ensure your PDF editing software supports JavaScript for interactive forms, and keep a backup copy of your original PDF document before adding custom scripts.

Solution 1Recommended

Use JavaScript on the Radio Button Action

Add a custom JavaScript action to the radio button's properties to dynamically update the target text fields when the user makes a selection.

By utilizing document-level scripts or field-specific actions, you can control the behavior of other form fields. The 'Mouse Up' trigger is generally recommended for radio buttons to ensure the script runs exactly when the user completes the click action.

1
Access Radio Button Properties

Open your PDF in form editing mode, right-click the specific radio button you want to act as the trigger, and select 'Properties' from the context menu.

2
Set Up the Action Trigger

Navigate to the 'Actions' tab in the Properties window. Choose 'Mouse Up' from the Select Trigger dropdown menu, select 'Run a JavaScript' from the Select Action dropdown, and click the 'Add' button.

3
Enter the Conditional Script

In the JavaScript Editor, write an if/else statement checking the radio button's export value. For example, if selected, use `this.getField('TargetField').value = 'N/A';` and `this.getField('TargetField').readonly = true;`. In the else block, set the value to `''` (blank) and `readonly = false;`.

4
Define the Default State

Ensure you account for the state where no radio option is selected yet. You can set the default properties of the text fields to be blank and editable until the script is triggered.

Use JavaScript on the Radio Button Action
Field Names Must Match: Ensure that the field names referenced in your JavaScript code exactly match the actual names of the text fields in your PDF form, as JavaScript is case-sensitive.

Easily Manage and Fill PDF Forms with WPS Office

WPS Office provides a robust and user-friendly PDF editor that allows you to easily view, fill, and manage interactive PDF forms without needing heavy or expensive software.

  1. 1. Download and Install: Download WPS Office for free and install it on your device.
  2. 2. Open Your PDF Form: Launch WPS Office, select the PDF tab, and open your interactive PDF document.
  3. 3. Fill and Interact: Click directly on the interactive form fields, radio buttons, or checkboxes to fill out the document.
  4. 4. Save Your Document: Once completed, click 'Save' to preserve your form data directly within the PDF file.
Easily interact with and fill out complex PDF form fieldsFully compatible with standard Adobe Acrobat PDF formatsLightweight alternative for fast PDF reading and editingCross-platform support for Windows, Mac, and mobile devices
QA img-9

Frequently Asked Questions

What should happen if neither radio button option is selected?

You should define a default state in your form design. Typically, the text fields should remain blank and editable (readonly set to false) until a specific radio button is clicked that triggers the locking script.

Can I apply this same logic to checkboxes instead of radio buttons?

Yes. You can apply a similar JavaScript action to a checkbox's 'Mouse Up' event. The script would check if the checkbox is checked (e.g., checking if its value equals its export value like 'Yes') and then lock or populate the target fields accordingly.

Why aren't my text fields updating when I click the radio button?

This usually happens if there is a syntax error in the JavaScript, if the field names in the script do not perfectly match the field names in the PDF, or if JavaScript execution is disabled in your PDF viewer's security preferences.