• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Form - Button inserts username and date

New Here ,
May 30, 2018 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

TOPICS
Acrobat SDK and JavaScript , Windows

Views

731

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
community guidelines

correct answers 1 Correct answer

Community Expert , May 30, 2018 May 30, 2018

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

Votes

Translate

Translate
Community Expert ,
May 30, 2018 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.

Votes

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
community guidelines
New Here ,
May 30, 2018 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.

Votes

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
community guidelines
Community Expert ,
May 30, 2018 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());

Votes

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
community guidelines
New Here ,
May 30, 2018 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());

};

Votes

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
community guidelines
Community Expert ,
May 30, 2018 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.

Votes

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
community guidelines
New Here ,
May 30, 2018 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...

Votes

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
community guidelines
Community Expert ,
May 30, 2018 May 30, 2018

Copy link to clipboard

Copied

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

Votes

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
community guidelines
New Here ,
May 30, 2018 May 30, 2018

Copy link to clipboard

Copied

LATEST

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

Votes

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
community guidelines