2 Replies Latest reply on Aug 4, 2015 12:16 PM by cfickncms

    Auto-populate the days of the week from a single field

    cfickncms

      I am trying to add a script that will auto-populate the days of the week from a single field. I've got a sample script that will populate the fields from today's date, but that is not what i'm looking for. I need the date to populate from a previous date which is entered from a separate field. Any help is appreciated.

       

      Here is the script I've pirated:

      var today = new Date() ;

      this.getField("sun").value = util.printd("mm/dd/yyyy", today) ; // fills field for today

      this.getField("mon").value = util.printd("mm/dd/yyyy", new Date(today.getFullYear(),today.getMonth(),today.getDate()+1)) ; // fills field for  monday

      this.getField("tue").value = util.printd("mm/dd/yyyy", new Date(today.getFullYear(),today.getMonth(),today.getDate()+2)) ; // fills field for tuesday

      this.getField("wed").value = util.printd("mm/dd/yyyy", new Date(today.getFullYear(),today.getMonth(),today.getDate()+3)) ; // fills field for wednesday

      this.getField("thu").value = util.printd("mm/dd/yyyy", new Date(today.getFullYear(),today.getMonth(),today.getDate()+4)) ; // fills field for  thursday

      this.getField("fri").value = util.printd("mm/dd/yyyy", new Date(today.getFullYear(),today.getMonth(),today.getDate()+5)) ; // fills field for friday

      this.getField("sat").value = util.printd("mm/dd/yyyy", new Date(today.getFullYear(),today.getMonth(),today.getDate()+6)) ; // fills field for saturday

       

      I know enough to be dangerous - then again maybe I don't.

       

      Thanks for your help.

      ~C