Copy link to clipboard
Copied
Hello,
I'm creating a form that includes a button that will automatically enter in the users Windows ID and current date and I'm having trouble finding a javascript on how to do this.
Any help that could be provide would be greatly appreciated.
Thanks,
Nathan
First thing to know is that it's JavaScript, not Java. Similar names, but very different languages.
You can use this code:
this.getField("Date").value = util.printd("mm/dd/yyyy", new Date());
Copy link to clipboard
Copied
The latter is easily done, the former not so much. You can access the "Login Name" property of the identity object, but it requires installing a script on the user's local machine.
Copy link to clipboard
Copied
Thanks. Any advise on how to do the date? This is the first form I'm creating with a button and I'm not too savvy with Java.
Copy link to clipboard
Copied
First thing to know is that it's JavaScript, not Java. Similar names, but very different languages.
You can use this code:
this.getField("Date").value = util.printd("mm/dd/yyyy", new Date());
Copy link to clipboard
Copied
Thanks again. So what I have now is but I still cant get it working...
document.getElementById("Button1").onclick = function() {
this.getField("Date").value = util.printd("mm/dd/yyyy", new Date());
};
Copy link to clipboard
Copied
Wait, are you talking about a web-page form, or a PDF form? My code (and this forum) is for the latter, only.
Copy link to clipboard
Copied
I'm trying to use what I found on the internet with what you provided. This is for a PDF form. I'm guessing I grabbed an HTML JavaScript...
Copy link to clipboard
Copied
It is. Use just what I provided as the Mouse Up event of your button.
Copy link to clipboard
Copied
Perfect. It works. Thank you again for all the help.