How to Toggle Between Two Button Icons in a PDF Form
Question details
The user wants to cycle between two different icons within a single PDF button field without relying on multiple buttons or document layers.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Creating dynamic and interactive PDF forms with a single button that changes its visual icon upon user interaction.
- Observed behavior
- The goal is to dynamically switch the icon of a single button field using JavaScript to extract and set the icon from hidden fields.
Ensure you have access to a PDF editor that supports advanced form field creation and JavaScript execution, and prepare the two image files you intend to use as icons.
Use Hidden Button Fields and JavaScript
Store your target icons in hidden fields and use a JavaScript mouse-up event to swap them seamlessly.
This method avoids the complexity of layering and keeps your document structure clean by leveraging built-in JavaScript methods to get and set button icons dynamically.
Add two button fields to your PDF form (e.g., 'IconA' and 'IconB'). In their properties, set their layout to 'Icon only', import your desired images for each, and set their visibility to 'Hidden'.
Draw the main visible button field where the user will click to toggle the icons.
Open the properties of the main button, navigate to the Actions tab, and set the trigger to 'Mouse Up'. Choose 'Run a JavaScript' from the action dropdown and click 'Add'.
Input a script that checks the current icon state using buttonGetIcon() and swaps it using buttonSetIcon(). For example: event.target.buttonSetIcon(this.getField('IconA').buttonGetIcon());

Create and Edit Interactive PDF Forms with WPS Office
WPS Office provides a comprehensive PDF editor that allows you to seamlessly create, manage, and fill interactive PDF forms without complex setups.
- 1. Open your PDF: Launch WPS Office and navigate to the PDF tab. Click on 'Open' to load your existing PDF document.
- 2. Access Form Tools: Navigate to the 'Form' tab on the top ribbon to access interactive form controls.
- 3. Add Interactive Fields: Select the desired field type, such as a Push Button, and draw it directly onto your document layout.
- 4. Configure Properties: Double-click the new field to open the properties panel, where you can easily customize its appearance, icons, and actions.

Frequently Asked Questions
Can I use standard images for PDF button icons?
Yes, you can import standard image formats like JPEG, PNG, or even other PDF pages to set as your button icon in most professional PDF editors.
Do I need to know JavaScript to create PDF forms?
Basic forms with text fields, dropdowns, and checkboxes do not require JavaScript. However, advanced interactive features like toggling icons dynamically usually require simple scripting.
Why are my PDF form buttons not working?
Interactive form buttons require a PDF viewer that supports interactive forms and JavaScript. Ensure your users are opening the file in a compatible desktop PDF reader rather than a basic browser viewer.
Can I hide fields in a PDF form?
Yes, in the field properties under the General tab, you can set the visibility status to 'Hidden'. This is commonly used to store data or icons needed by scripts without cluttering the page layout.




