Announcement

Collapse
No announcement yet.

Set field value to current date

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • FAQ Set field value to current date

    Hi

    I'm trying to accomplish a seemingly simple task, that is, to set the value of a field to the current date when the document is opened.

    I've tried numerous variations using javascript and a "calculated" value, no effect.

    I am able to set the value using a triggered script, such as Mouse Enter, so I know the js is working. But as a Calculated Value, I can't seem to get the right syntax.

    My other guess would be to trigger a script when the document opens, but I can't find a way to do that either. I tried using "Document Javascript", but nothing triggers.

    Thanks!

  • #2
    You can write to [email protected] for applying js reference document for your information.

    Comment


    • #3
      Please refer to below js code:

      var myDate = new Date();
      var time = myDate.toLocaleString();
      this.getField("Demo").value = time;

      Comment


      • #4
        Hi, thanks for the replies.

        I have my js:
        Code:
        this.getField("Date").value = util.printd("yyyy-mm-dd", new Date());
        working the way I need it to, my problem is getting it to execute automagically.

        As I mentioned, I can get an event like "Mouse Enter" or "On Receive Focus" to trigger it, but these are field-level events. What I was hoping for was something at a document level, like a "Document Open" type event that would run the code without needing any user interaction.

        Even if there was a way to give the field focus automatically, I could work with that.

        Is your "js reference document" any different than the one available from the Adobe web site? I only ask because much of your other documentation quotes the Adobe doc verbatim.

        Thanks!

        -Glenn

        Comment

        Working...
        X