1
0
-1

Hi All,

I have the following:

Form: ht_cpo_item

Two Date Picker fields:

  • Plan del date - cpo_item_plan_del_date eg. I will put in the form eg. 2016-03-01
  • Plan billing date - cpo_item_plan_billing - here I would like to have always + 10 days from cpo_item_plan_del_date I will get in the form eg. 2016-03-11

I was trying to use hash variable in Default value of cpo_item_plan_billing with reference to  #form.ht_cpo_item.cpo_item_plan_del_date# and somehow add 10 days but no luck.

I have checked hash variable #date.DAY+10.EEE, d MMM yyyy h:mm:ss a# it works but from current date.

Any thoughts?

BR,

Sylwester

 

 

    CommentAdd your comment...

    2 answers

    1.  
      3
      2
      1

      Hi All,

      I found out it How to get date picker value and add days at the same form

       

      <script>
           $(document).ready(function(){
                var dateField = FormUtil.getField("cpo_item_plan_del_date");
                var hiddenField = FormUtil.getField("cpo_item_plan_billing");
                var updateDueDate = function (field, selectedDate) {
                     console.log($(field));
                     console.log($(dateField));
                     if ($(field).attr("id") === $(dateField).attr("id")) {
                         var instance = $(field).data( "datepicker" );
                         var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings );
                         date.setDate(date.getDate() 10);
                         var dateString = $.datepicker.formatDate(instance.settings.dateFormat, date, instance.settings);
                         $(hiddenField).val(dateString);
                     }
                };
                $.datepicker.setDefaults({
                      onSelect: function( selectedDate ) {
                              updateDueDate(this, selectedDate);
                      }
                });
           });
      </script>
        CommentAdd your comment...
      1.  
        1
        0
        -1

        hi Sylwester Nowak,

        good job, always success..

          CommentAdd your comment...