How to Automatically Create Sequential Numbers in a PDF Form
Question details
The user needs to dynamically generate sequence labels (e.g., '1 of 15', '2 of 15') in a PDF shipping form based on a total quantity entered by a worker.

- Product
- Adobe Acrobat / PDF Form
- Device & OS
- not provided
- Scenario
- A worker fills out a shipping form and enters a total box quantity. The document should automatically populate the corresponding labels for each box.
- Observed behavior
- The user requires a method or script to link individual sequence fields to the total quantity field so they update automatically when the total is entered.
Ensure you are using a professional PDF editor that supports interactive form creation and JavaScript calculations, and that you have already mapped out where your sequence labels will be placed on the document.
Use Custom JavaScript Calculations for Text Fields
Create a master input field for the total quantity, and set up individual text fields with custom calculation scripts to generate the sequential labels.
Interactive PDF forms can utilize JavaScript to combine fixed text (like the current sequence number) with variable data (like the total quantity entered by the user). By configuring the calculation properties of individual text fields, you can achieve automatic sequential numbering.
Open your PDF editor's form mode. Insert a Text Field where the worker will type the total number. Right-click the field, select Properties, and name the field exactly 'TotalQty'.
Create separate Text Fields for each label you need to generate (e.g., for box 1, box 2, etc.). Name these fields uniquely, such as 'Label1', 'Label2', and so on.
Right-click the first sequence field ('Label1') and select Properties. Navigate to the Calculate tab, select 'Custom calculation script', and click Edit.
Type the following script: event.value = '1 of ' + this.getField('TotalQty').value; and click OK. Repeat this process for 'Label2' changing the script to '2 of ', and continue for the rest of your sequence fields.
Exit form editing mode and type a number like '15' into the 'TotalQty' field. Press Enter or click outside the box to verify that the sequence labels instantly update to '1 of 15', '2 of 15', etc.

Create and Manage Interactive PDF Forms with WPS Office
WPS Office includes a comprehensive PDF editor that makes it incredibly easy to design interactive forms, insert text fields, and manage properties without needing complex standalone software.
- 1. Open your PDF in WPS: Launch WPS Office, select the PDF tab, and open your existing document or start a new blank PDF.
- 2. Access the Form Tab: Click on the 'Form' tab on the top ribbon to reveal the interactive form controls.
- 3. Insert Text Fields: Select 'Text Field' and drag your cursor on the page to draw input boxes for your total quantity and sequence labels.
- 4. Customize Properties: Double-click the inserted text fields to open the Properties menu, where you can define names, formatting, and behavior.

Frequently Asked Questions
Can I dynamically spawn new pages based on the total quantity entered?
Standard PDF forms do not natively support spawning new pages from templates simply by entering a number in a text field. This requires advanced document-level JavaScript and specific security permissions (often restricted to Acrobat Pro). It is recommended to pre-create the maximum number of fields or pages you might need.
Why isn't my sequence label updating when I type the total quantity?
This usually happens if the calculation order is incorrect or if the field names in your JavaScript do not exactly match the actual field names (remember that JavaScript is case-sensitive). Ensure 'TotalQty' matches the master input field name perfectly.
Can I do this without using JavaScript?
No, standard PDF forms require JavaScript to perform string concatenation (combining the fixed text '1 of ' with the dynamic total quantity). Without JavaScript, you would have to type the sequences manually.




