1 Reply Latest reply on Jul 21, 2015 6:27 AM by try67

    Javascript to add days to date field

    yohjp

      I have five radio buttons that I am trying to add days to the current date field on the form to new field--due date.

       

      First four are relatively easier. But the last 'type5' is part of the radio group that I was wondering if I can include federal holidays to be accounted for in the date calculation. If that is not possible or too complex, is it possible to have that selection be freeform text (user can enter date based off the date format)?

       

      var date = new Date();

      var addTime = this.getField("group1").value;

      var days = 0;
      if (addTime != "Off") {
          switch (addTime) {
          case "type1" :
              days = 10;
              break;
          case "type2" :
              days = 5;
              break;
          case "type3" :
              days = 60;
              break;
          case "type4" :
              days = 10;
              break;   
          }
          date.setDate(date.getDate()+days);
          event.value = util.printd("mm/dd/yyyy", date);
      }
      else {
          event.value = "";
      }

        • 1. Re: Javascript to add days to date field
          try67 MVP & Adobe Community Professional

          It is possible to account for holidays in the calculation, but it requires a much more complex script.

           

          If you want the field to be editable then you should not have a custom calculation script for it, but instead move the code to the MouseUp events of the radio-buttons.