Copy link to clipboard
Copied
Hello! I am trying to create a sales tracker for a commisson based job. I'm wanting to be able to have a date field that when I choose a date, it will take the information from a previous page in the form and insert into a table. For example, if I choose January 5th in the date field, I would like it to copy the sales and tips fields from a previous page into new fields underneath the date on a different page. Is there a simple way to do this? Thanks in advance for your help!
Copy link to clipboard
Copied
Hi @DarthShayder,
Hope you are doing well. Thanks for writing in!
What you're trying to do is definitely possible, but it does require a bit of JavaScript to make it dynamic, since forms don’t natively support “auto-populating tables based on a date selection” out of the box.
Here's something you can try:
Ensure your fields are named in a way that makes scripting easy. For example:
Page 1:
sales_0105
(for Jan 5 Sales)
tips_0105
(for Jan 5 Tips)
Page 2:
date_select
sales_output
tips_output
You can add a custom script to trigger when the date_select
field is modified.
Here’s a sample script:
var dateStr = this.getField("date_select").value;
// Convert date to MMDD format
var dateObj = util.scand("mm/dd/yyyy", dateStr);
if (dateObj !== null) {
var month = (dateObj.getMonth() + 1).toString().padStart(2, "0");
var day = dateObj.getDate().toString().padStart(2, "0");
var key = month + day;
// Get values from Page 1
var salesValue = this.getField("sales_" + key).value;
var tipsValue = this.getField("tips_" + key).value;
// Populate fields on Page 2
this.getField("sales_output").value = salesValue;
this.getField("tips_output").value = tipsValue;
}
Here's how to add the script:
Open your form in Acrobat.
Select the date_select
field.
Go to Properties (right-click → Properties or use the Prepare Form tool).
Go to the "Actions" tab.
Choose:
Trigger: On Blur
(or On Focus Lost
)
Action: Run a JavaScript
Click Add... and paste the script above.
Click OK and save your form.
Hope this helps.
Regards,
Souvik.
Copy link to clipboard
Copied
I believe this response may have come from ChatGPT or a similar AI platform. While AI-generated answers can sometimes be helpful, they aren’t always accurate—especially when it comes to specific environments like Acrobat JavaScript.
As an Adobe employee, it's important to note that the padStart()
method is not supported in Acrobat's JavaScript engine, which is based on an older ECMAScript version.
Copy link to clipboard
Copied
Name the fields on both pages identically.
Copy link to clipboard
Copied
Does date matter, or you just want to copy field values to new fields when you select date?
Copy link to clipboard
Copied
The dates matter. I want my co workers to be able to use it as well, but we all prk different days. I also don't want to have to go back and redo it each year.
Copy link to clipboard
Copied
Sorry, let me explain it a bit better. I want to have a chart that shows the totals for the 4 or 5 days they worked, and then at the end of the "week" they can see what their totals are, and on pay weeks, see their estimated paycheck. So, day by day they'll have how much each sale is and any tips, with daily totals on those days, but then toward the end of the document, it'll show their monthly view of total sales and tips for the days they worked, with the end of the week showing the weekly total. If I need to upload a screenshot I can.
Copy link to clipboard
Copied
Yes, please do, or share the actual file.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Since there are so many fields in your file I would recommend against doing it automatically. You should use a button that when clicked collects all the data from the calendars and copies it to the summary pages at the end of the page. Otherwise you will have serious delays each time the user enters anything into any of the fields.
Copy link to clipboard
Copied
That makes sense. I was kinda thinking that's what the date button could do. So if I were to add a date field to choose January 3rd, it would trigger something that would copy the "Totals" fields to the labeled area underneath it. Some coworkers only work 4 days, and they work some Saturdays, so I want them to be able to have accurate dates for their tracker at the end.
Copy link to clipboard
Copied
It is still not clear to me exactly what you are trying to accomplished. Where will the the date field be, or are you going to have buttons for each day on the page 1 calendar. Can you please provide a specific example. What data should go where when what happens. "Is there a simple way to do this?" Probably not. But it looks like you took a lot of time manually naming your fields. At first glance of the field names I spotted a couple of errors in the pattern. It would've been a lot easier to to create one row of field and use right-click > Create multiple copies to get field names with numbered suffixes, or run a script to place your fields programatically. It takes some thought in field naming for a project like this and then a written function in a document level script that you call in the fields that will trigger what you want to occur. This might help:
https://pdfautomationstation.substack.com/p/anticipating-field-names-in-custom