Skip to main content
New Participant
April 10, 2025
Answered

Copying specific Form fields from one page to another based on specific date field

  • April 10, 2025
  • 3 replies
  • 1434 views

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!

Correct answer PDF Automation Station

Here's the file.


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

3 replies

Nesa Nurani
Community Expert
April 10, 2025

Does date matter, or you just want to copy field values to new fields when you select date?

New Participant
April 11, 2025

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.

PDF Automation Station
Community Expert
April 11, 2025

Here's the file.


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

PDF Automation Station
Community Expert
April 10, 2025

Name the fields on both pages identically.

S_S
Community Manager
Community Manager
April 10, 2025

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.

Nesa Nurani
Community Expert
April 10, 2025

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.