Need to insert javascript into a text box in Adobe LiveCycle

I would like to implement the follow javascript action in a text field.  I use it in Acrobat but have not been able to get it working in LiveCycle.  This script will enter in today's date into the field once the user clicks into it.


if(this.getField("todaysDate").value == "") {

var d = new Date();

var sDate = util.printd("mm/dd/yyyy", d);

this.getField("todaysDate").value = sDate;

}

Thanks, Jon
Jonathan SuberIT DirectorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ivano ViolaSystem AdministratorCommented:
Jon,

I use the following to populate the Date/Time field on Form DocReady. This may work for you.

IV
DateTime-Example.pdf
0
Jonathan SuberIT DirectorAuthor Commented:
Does this script always pull in the current date/time?  My script will put in the current date but then it never changes so if I pull it up a month from now, it will still show the original date.  Thanks, JDS
0
Ivano ViolaSystem AdministratorCommented:
Jon,

What about this?

I added the following javascript in the docReady section:

if (todaysDate.rawValue == null)
{
Now = new Date();
todaysDate.formattedValue = util.printd("mm/dd/yyyy", Now);

}

IV
Date-Example.pdf
0
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

Jonathan SuberIT DirectorAuthor Commented:
Can this script be initiated by the user?  

Right now I have a table with 10 rows and 10 date fields.  Not all the date fields will have the same date in them.  

Currently in Acrobat, my users can click into the date field and it will populate with todaysDate.  I can't get that feature to work after I moved the form into LiveCycle...yet.

Thanks, Jon
0
Ivano ViolaSystem AdministratorCommented:
I moved the javascript to the Enter section for the field. So when you click into the date field it will populate the field with the date.

IV
Date-Example.pdf
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jonathan SuberIT DirectorAuthor Commented:
That's nice.  Can you advise me the how can I implement it into my forms?  I am getting more familar with LC as I work on this project.

Thanks for all your help, Jon
0
Ivano ViolaSystem AdministratorCommented:
You have to show the Script Editor window. Check the following from the toolbar menu:
Window - Script Editor

Also check:
Window - Hierarchy

Then you should see the following:
Settings
Click on the Date field and select "Enter" from the Show drop-down. The javacript should be there.

IV
0
Jonathan SuberIT DirectorAuthor Commented:
Thank you....I can see that on my end now.

I have a small problem.  I pulled up the example form from yesterday and it had todays date populated in the date filed.  It should of had yesterday's date in that field.  It looks like your script is always populating the field with the current date.  Is there a way to keep the initial date in that field?  Thanks, Jon
0
Ivano ViolaSystem AdministratorCommented:
I tested the form and it seems to be working ok. I inserted today's date and saved the form. I then changed the system date on my computer. I reopened the form and the original date was still there....it did not update the date with the date I changed it to.

IV
0
Jonathan SuberIT DirectorAuthor Commented:
My apologies!  I did the same test as you and it is working.  Not sure what happened before.  User error!  Thanks!  Jon
0
Jonathan SuberIT DirectorAuthor Commented:
Ivanoviola is great to work with and is very intelligent.
0
Ivano ViolaSystem AdministratorCommented:
Great that it's working. Just a hint.....Sometimes to be able to save information into the pdf, you have to enable additional features. This is done by doing a "Save As" on the document in Adobe Acrobat Pro.

Here is an image. This allows information to be saved into the pdf. You only have to do this once for the form. I'm using Pro X. It may be in a different place on earlier versions.

Enable Additional Features
If you need anything else just ask. I'm happy to help. :)

IV
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Acrobat

From novice to tech pro — start learning today.