How to Create Clickable Tally Marks and Checkboxes in PDF Forms
Question details
The user wants to design an interactive PDF form that allows users to add or remove tally marks or clickable check marks, optionally limiting the number of marks per box.

- Product
- Device & OS
- not provided
- Scenario
- Designing interactive PDF forms for surveys, tracking, or specialized data collection that requires non-standard checkboxes or tally counters.
- Observed behavior
- The user needs a programmable method to register clicks, display visual tally marks at specific page coordinates, and ensure that end-users cannot accidentally move the drawn elements.
Creating custom clickable tally marks requires intermediate to advanced knowledge of PDF JavaScript and coordinate plotting. Ensure your PDF editor supports JavaScript execution and advanced form field customization before proceeding.
Implement Clickable Tally Marks Using JavaScript and Line Annotations
The most effective way to create a toggleable tally mark is to use JavaScript to add and remove a read-only line markup annotation at specific coordinates when a button is clicked.
Instead of complex custom graphics, using standard line markup annotations triggered by form buttons is more reliable. By scripting the button to read its current state, you can toggle the line on or off.
Since PDF page coordinates dictate exactly where the line appears, the script must calculate the precise location over the button. The annotation should also be set to read-only so the end-user cannot drag it out of place.
Open your PDF editor's Form tools and insert a 'Button' field over the area where you want the tally mark to appear. Set its fill and border colors to transparent.
Right-click the newly created button, select 'Properties', and navigate to the 'Actions' tab.
Set the trigger event to 'Mouse Up' and choose 'Run a JavaScript' from the action dropdown menu, then click 'Add'.
Enter the JavaScript code to detect the button's bounding box coordinates. Use the 'addAnnot' method to draw a line annotation across these coordinates. Include conditional logic to delete the annotation if it already exists, effectively creating a toggle.
Within your script, immediately set the newly created annotation's readOnly property to true (e.g., 'annot.readOnly = true') to prevent users from dragging the line elsewhere.

Easily Create Interactive PDF Forms with WPS Office
While advanced JavaScript programming is necessary for custom tally marks, WPS Office provides an intuitive suite of built-in form controls. You can easily add standard checkboxes, radio buttons, and text fields without writing complex code.
- 1. Open your PDF file: Launch WPS Office and open the PDF document you want to turn into an interactive form.
- 2. Navigate to the Form tab: Click on the 'Form' tab on the top ribbon to access the interactive form creation tools.
- 3. Insert Checkboxes: Select the 'Check Box' tool from the menu and click anywhere on the page to place a standard, clickable checkbox.
- 4. Customize form properties: Double-click the inserted checkbox to modify its appearance, set its export values, and rename the field for easy data collection.

Frequently Asked Questions
Can I use custom graphic images as checkboxes in a PDF?
Yes, but it requires advanced scripting to swap button icons dynamically or toggle the visibility of image fields based on user clicks, rather than using built-in form tools.
Why can users move the tally marks I created with JavaScript?
By default, PDF annotations can be selected and moved. You must set the annotation's property to read-only within your JavaScript code (e.g., annot.readOnly = true) right after creating it.
How do I limit a PDF form box to a maximum of three clicks?
You can declare a counter variable in your document-level JavaScript. Each time the button is clicked, increment the counter. If the counter exceeds three, you can use an if-statement to prevent further annotations from being drawn.
Are custom JavaScript tally marks supported on mobile PDF readers?
Most mobile PDF viewers have limited or no support for complex JavaScript and dynamic annotations. Standard form checkboxes are heavily recommended if your document will be filled out on smartphones or tablets.




