Skip to main content
Known Participant
November 28, 2024
Question

Automatically fill date field when a check-box is ticked

  • November 28, 2024
  • 1 reply
  • 6522 views

I have created a form which will be filled in over several days. When a checkbox is ticked, I want the date field next to it to automatically fill in with today's date. I don't want this entry to update when the date changes; it needs to record when that particular box was ticked.

Please could you help me write a script to help this occur? I have to then cover about 40 pages with the same fields, so would like to get it right before I go on a copying session! Thanks very much.

This topic has been closed for replies.

1 reply

PDF Automation Station
Community Expert
November 29, 2024

Enter the following mouse up action script in the check box (assuming the text field name is Date):

if(!this.getField("Date").value && event.target.value!="Off")

{this.getField("Date").value = util.printd("mm/dd/yyyy", new Date());}

The blue text ensures the date will not update after it has already been entered.  If you want it to update every time the box is checked, remove the blue text from the script.

Known Participant
November 29, 2024

Thanks so much! It looks like that has worked. Is there a quick way of duplicating both the check box and date field 6 times on 40-odd pages? Will it update the field names automatically in the Javascript? I know how to do multiple copies, etc.

Known Participant
November 29, 2024

What are you trying to do:

1)  Create one check box that fills in multiple date fields?

2)  Create multiple checkbox/date field pairs where each check box fills in the date for a different text box?


2. I'm sorry to ask so many questions. other text boxes/dropdowns are contained but these 2 are the only ones which need automating. They are all repeated on each page.