Skip to main content
Participating Frequently
January 18, 2016
Question

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

  • January 18, 2016
  • 1 reply
  • 274 views

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



This topic has been closed for replies.

1 reply

Inspiring
January 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.

hpdouet84Author
Participating Frequently
January 18, 2016

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.