Skip to main content
Known Participant
November 28, 2024
질문

Automatically fill date field when a check-box is ticked

  • November 28, 2024
  • 1 답변
  • 6526 조회

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.

이 주제는 답변이 닫혔습니다.

1 답변

PDF Automation Station
Community Expert
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.

PDF Automation Station
Community Expert
Community Expert
November 29, 2024

Stupid question but you said to put the date trigger checkbox right next to the date field - does that mean I have to change where the checkbox is at the moment? As that is going to cause me some troubles. If I try to create a copy of the original checkbox & date field then none of them work.


The location doesn't matter.  I said to put it next to it so it's easy to create multiple copies of both simultaneously.