Skip navigation
CommodoreHero
Currently Being Moderated

If I enter today's date in Box 1, how can I get Box 2 to auto-fill the same date +30 days?

Jun 19, 2012 4:27 PM

Tags: #field #javascript #form #scripting #acrobat_forms #adobe_acrobat_x_pro #acrobat_x_pro_help

If I enter today's date in Box 1, how can I get Box 2 to auto-fill the same date +30 days?

 
Replies
  • George Johnson
    9,208 posts
    Aug 11, 2002
    Currently Being Moderated
    Jun 19, 2012 10:55 PM   in reply to CommodoreHero

    You can use the following script for the custom Calculate script for the Box 2 field:

     

    // Custom calculate script for Box 2 field
    (function () {

        // Get date from field
        var v = getField("Box1").valueAsString;

        // Convert string to date
        var d = util.scand("mm/dd/yyyy", v);

        // Add 30 days
        d.setDate(d.getDate() + 30);

        // Populate this field with the result
        if (v) {
            event.value = util.printd("mm/dd/yyyy", d);
        } else {
            event.value = "";
        }

    })();

     

    Replace "Box1" in the code above with the actual name of the field.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points