Form - Button inserts username and date

New Here ,
May 30, 2018

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

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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());

TOPICS
Acrobat SDK and JavaScript, Windows

Views

154

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Form - Button inserts username and date

New Here ,
May 30, 2018

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

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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());

TOPICS
Acrobat SDK and JavaScript, Windows

Views

155

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 30, 2018 0
Most Valuable Participant ,
May 30, 2018

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 30, 2018 0
New Here ,
May 30, 2018

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 30, 2018 0
Most Valuable Participant ,
May 30, 2018

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());

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 30, 2018 0
New Here ,
May 30, 2018

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());

};

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 30, 2018 0
Most Valuable Participant ,
May 30, 2018

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 30, 2018 0
New Here ,
May 30, 2018

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...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 30, 2018 0
Most Valuable Participant ,
May 30, 2018

Copy link to clipboard

Copied

It is. Use just what I provided as the Mouse Up event of your button.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 30, 2018 0
NathanDF LATEST
New Here ,
May 30, 2018

Copy link to clipboard

Copied

Perfect. It works. Thank you again for all the help.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 30, 2018 0