Print Page | Close Window

Javascript in PDF forms

Printed From: Foxit's Planet PDF Forum
Category: Lets Talk PDF
Forum Name: JavaScript
Forum Description: Discussions relating to the use of JavaScript within PDF.
URL: http://forums.planetpdf.com/forum_posts.asp?TID=1868
Printed Date: 22 Oct 2019 at 3:16pm
Software Version: Web Wiz Forums 11.10 - http://www.webwizforums.com


Topic: Javascript in PDF forms
Posted By: oakridge92
Subject: Javascript in PDF forms
Date Posted: 28 Oct 2015 at 5:14pm
I am very new to PDF forms and to javascript.  I got handed this responsibility for our office about 3 days ago.  I am attempting to get a date field (titled "today") in my form to be automatically filled with the current date each time the form is opened.  I have been searching for a few hours for javascript to make this work and have found 8 different scripts, tried them all, and none of them worked at all.  The text field does not autofill but I can still type into it. 
 
I am using Acrobat X Pro and also have access to LiveCycle Designer ES2.  Any help any of you can give would be greatly appreciated.


-------------
oakridge92



Replies:
Posted By: Horndoggie
Date Posted: 28 Oct 2015 at 6:21pm

//current date

var f = this.getField("Today");
f.value = util.printd("mm/dd/yyyy", new Date());


-------------
Doug


Posted By: oakridge92
Date Posted: 28 Oct 2015 at 6:36pm
Hey Doug,
 
Thanks for the response.  I tried this too and still get nothing in the text field.  I have not done anything weird with the properties for the text box so I am not sure why it will not autofill.
 
 


-------------
oakridge92


Posted By: BAlheit
Date Posted: 29 Oct 2015 at 8:12am
Where did you add the code?


Posted By: oakridge92
Date Posted: 29 Oct 2015 at 11:46am
I put it into the "Actions" area with the action set as Run a JavaScript.

-------------
oakridge92


Posted By: BAlheit
Date Posted: 29 Oct 2015 at 3:07pm
Then you must click with the mouse into the field.

Add the code at document level.


Posted By: gkaiseril
Date Posted: 29 Oct 2015 at 6:14pm

As noted the best place for this code is in the document level area so the code is only run once when the document is opened, but you will the Professional version to access this trough the UI. with standard you can use a script.

The next best place would be in  Page Open action, the code will run when the page is opened or one enters the page. You might want to add some cod so the code only runs once per open session with the PDF.

You might also want to verify that the field name in the script is exactly the same as the field's name. Spelling and capitalization must be exactly the same. 



Posted By: Horndoggie
Date Posted: 29 Oct 2015 at 6:22pm
I'm sorry.  I got side tracked and never got back here.  I didn't realize you didn't know where to put it my bad.  Sorry for the confusion.

-------------
Doug



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.10 - http://www.webwizforums.com
Copyright ©2001-2017 Web Wiz Ltd. - https://www.webwiz.net