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

Who can help me with a calculated date to a drop down box?

New Here ,
Jan 17, 2016 Jan 17, 2016

I'm trying to add 2 calculated dates to a drop down for the release date on a form I am currently working on. I can get the 1st one in there but not the 2nd.  In the "Options" tab I only have "Permanent" listed. In the "Calculate" tab I have the following custom calculation script:


(function () {

    // Get date from field
    var v = getField("Today").value;

    if (v) {

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

        // Add 14 days
        d.setDate(d.getDate() + 14);
        // Set value of this field to the new date
        event.value = util.printd("mm/dd/yyyy", d);

    } else {

        // Blank field if no date entered
        event.value = "";
    }
})();(function () {

    // Get date from field
    var v = getField("Today").value;

    if (v) {

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

        // Add 180 days
        d.setDate(d.getDate() + 14);
        // Set value of this field to the new date
        event.value = util.printd("mm/dd/yyyy", d);

    } else {

        // Blank field if no date entered
        event.value = "";
    }
})();

The Release Date dropdown would show the following date options:

-        “Today’s Date” + 14 days

-        “Today’s Date” + 180 days

-        Permanent



TOPICS
Acrobat SDK and JavaScript
246
Translate
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
LEGEND ,
Jan 18, 2016 Jan 18, 2016

Your script needs to check the dropdown's value to determine  the number of days to add. You might also want to add some code to ensure the user has selected a number of days.

I am not sure why you need to post multiple questions about this issue.

Translate
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 ,
Jan 18, 2016 Jan 18, 2016
LATEST

I'm new to this so my apologies for posting multiple questions about this issue.  I wasn't sure if I had posted the 1st one correctly.

Translate
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