Use Acrobat JavaScript to Make One PDF Form Page Editable
Question details
Make only the PDF form fields associated with one of three radio-button choices editable.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A form has three choices, each corresponding to a different page or group of fields.
- Observed behavior
- Selecting a choice should enable its associated fields and make the other groups read-only.
In Acrobat's Prepare a form tool, identify the radio-button group name, each choice's export value, and the exact names of the fields in each group. Make sure the fields in the three groups have distinct names.
Set field groups to read-only with an Acrobat calculation script
Use this approach when each radio-button choice should enable a different set of PDF form fields.
The script changes individual fields, not entire pages. Include every field that should be controlled in the appropriate group, but do not include the radio-button group itself.
The example uses Group1 as the radio-button group and Choice1, Choice2, and Choice3 as its export values. Replace these and the field names with the values in your form.
Open the PDF in Acrobat, then choose All tools > Prepare a form. Check each radio button's Properties > Options for its export value and each field's Properties for its name.
In Prepare a form, open each controlled field's Properties and select Read Only on the General tab. Leave the radio-button group editable so the user can make a selection.
Use Prepare a form to add a text field named FormController. Open its Properties, set it to Hidden on the General tab, and select Calculate > Custom calculation script > Edit.
Paste the following script into the JavaScript editor, replace the example names, and click OK: var choice = this.getField("Group1").valueAsString; var groups = { Choice1: ["Page1_Name", "Page1_Check"], Choice2: ["Page2_Name", "Page2_Check"], Choice3: ["Page3_Name", "Page3_Check"] }; for (var key in groups) { for (var i = 0; i < groups[key].length; i++) { var field = this.getField(groups[key][i]); if (field) field.readonly = (choice !== key); } }
Save the form and use Preview in Prepare a form to select each radio button. Confirm that only its fields are editable; also test the form with no choice selected. If it does not update, check the field names and Acrobat's JavaScript and automatic field calculation settings.

Work with PDFs and Office files in WPS Office
WPS Office is a free, lightweight alternative for working with documents in a familiar interface. Open common Office formats for an easier move between suites and use its PDF tools for everyday document work. For the conditional Acrobat JavaScript form above, continue to use Acrobat and test compatibility in the intended PDF viewer.

Frequently Asked Questions
How do I find a radio button's export value in Acrobat?
Open All tools > Prepare a form, open the radio button's Properties, and check the Options tab. Use its export value in the script, matching capitalization and spelling.
What happens if no radio button is selected?
The script makes every listed field read-only when the group value does not match Choice1, Choice2, or Choice3. Set the controlled fields to Read Only initially so the form also starts in that state.
Why does a field remain editable after I select another choice?
In Prepare a form, check that the field's exact name appears in the correct script array. Also check that Acrobat JavaScript and automatic field calculation are enabled, then test again in Preview.
Will switching choices delete a user's previous entries?
No. The script changes the fields' read-only properties but does not clear their values. A separate clearing action would be needed if the form requires it.
Will this form work in every PDF viewer?
Not necessarily. PDF viewers differ in their support for Acrobat JavaScript and form calculations. Test the saved form in each viewer that recipients are expected to use.




