Copier le lien dans le Presse-papiers
Copié
When I select the date/time field, it displays the minutes with a value of :05, even though the system time shows the real current time.
Copier le lien dans le Presse-papiers
Copié
I don't see any buttons for setting the time when the user clicks them... So I added them for you, just above the first two fields, and applied the code to them. I also removed all other code fragments you had under those fields, and set their Format to None. See attached.
Copier le lien dans le Presse-papiers
Copié
Thank you much! Now I see where I was going wrong. I had a button at the top of the form I was playing around with, but what I didn't do was reference the Text field from the Button in the Javascript. Also, I didn't set the Action of the Text field to Execute a Menu Item.
Copier le lien dans le Presse-papiers
Copié
When you specify the pattern make sure to use upper-case letters, as "mm" stands for Month, not Minutes (which is "MM"). Hence the "05" result you're getting...
Copier le lien dans le Presse-papiers
Copié
Thank you. That was the issue! However, now I am noticing that h, MM and ss only display the time when the form was first opened. In other words, they are not pulling the current system time, and I can only assume that mm and dd would do the same thing, if I waited long enough to test that theory. Is this by design? Is there a way to get current system time just like the digital signature does?
Copier le lien dans le Presse-papiers
Copié
It's possible, but you need to define exactly when it should be updated. What should be the trigger for it?
Copier le lien dans le Presse-papiers
Copié
Well, ideally what we would like are Start and Stop buttons for the user to just click and record the current system time. This will help them keep track of how much time they are spending on specific tasks. Sort of like a stop watch. The simplest way I found (without writing Javascript) is to just have the user select a date field and select the current day. By adding the time to the format, the user would be recording the current date and time.
Copier le lien dans le Presse-papiers
Copié
If you want to do it via a button then it has to be done using a script.
Copier le lien dans le Presse-papiers
Copié
Yes, we would want to use a button but would need help writing a script. So in lieu of that, what we need is to just see the function work. We will take the simplest method just as long as we can get the current system time. The field type and trigger could be anything at this point.
Copier le lien dans le Presse-papiers
Copié
Look at this article:
https://acrobatusers.com/tutorials/working-date-and-time-acrobat-javascript-part-3-3/
Copier le lien dans le Presse-papiers
Copié
The code itself is very simple:
this.getField("Date1").value = util.printd("mm/dd/yyyy HH:MM", new Date());
Adjust the field name and/or date pattern as needed.
Copier le lien dans le Presse-papiers
Copié
Thank you. I will let you know how it works out for me.
Copier le lien dans le Presse-papiers
Copié
What type of field is this code using? If I use a date field, it doesn't use the Javascript. If I change the field type to none, it also doesn't seem to use the Javascript. I am making certain the field name is the same. There are also no script errors when I add the Javascript Actions -> On Focus -> Run Javascript.
this.getField("Date1").value = util.printd("mm/dd/yyyy HH:MM", new Date());
Copier le lien dans le Presse-papiers
Copié
The trigger should be the Mouse Up event of a button field, and the target should be a text field, with the Format set to None or to Date.
Copier le lien dans le Presse-papiers
Copié
Apologies in advance for my ignorance, but I am not understanding how a button field and text field are linked together. Button Properties only show me the Actions tab where I can define a Mouse Up event to run JavaScript, whereas Text Field Properties show me Actions, Format, Validate, and Calculate tabs.
Copier le lien dans le Presse-papiers
Copié
You wrote: "ideally what we would like are Start and Stop buttons for the user to just click and record the current system time."
Well, my code does just that. It uses the Mouse Up event of a button field to populate a text field with the current system time.
Copier le lien dans le Presse-papiers
Copié
I am sure your code works, but I am just not connecting the dots to get it setup correctly.
Copier le lien dans le Presse-papiers
Copié
I don't know how to explain it any more clearly than that... If you want further help you'll need to share the actual file.
Copier le lien dans le Presse-papiers
Copié
Copier le lien dans le Presse-papiers
Copié
Copier le lien dans le Presse-papiers
Copié
Thank you much! Now I see where I was going wrong. I had a button at the top of the form I was playing around with, but what I didn't do was reference the Text field from the Button in the Javascript. Also, I didn't set the Action of the Text field to Execute a Menu Item.
Copier le lien dans le Presse-papiers
Copié
> Also, I didn't set the Action of the Text field to Execute a Menu Item.
Nor should you have...