1
0
-1

dear experts,

I have 2 form, A and B.

Form B contain the list of dates (7 dates) and the calculation executed here

Form B also act as subform in form A

below is the codes to calculate the difference between dates,

It works perfectly when in preview mode. but the scipt would not work when i place form B as subform

 

<script type="text/javascript">

$(function(){
$('input[name="dateStart"], input[name="dateEnd"]').change( function(){
      d1 = $('input[name="dateStart"]').datepicker('getDate');
      d2 = $('input[name="dateEnd"]').datepicker('getDate');
      diff = 0;
      
      diff = Math.floor((d2.getTime() - d1.getTime()) / 86400000); // ms per day
      diffy = Math.floor((d2.getTime() - d1.getTime()) / 86400000); // ms per day
      
      
      $('input[name=days1]').val(diff);
      $('input[name=datediff1]').val(diffy);
});

});

    CommentAdd your comment...

    2 answers

    1.  
      1
      0
      -1

      Hi

      i used this codes

      var fieldD1 = FormUtil.getField("dateStart");
      var fieldD2 = FormUtil.getField("dateEnd");

      var fieldD3 = FormUtil.getField("test");
      $(fieldD3).val(fieldD1);

       

      The results = Object object

       

      How to solve ya??? thanksss

       

      1. Anders

        Instead of using fieldD1 which is the actual field, you can try using fieldD1.val() to obtain the value.

      CommentAdd your comment...
    2.  
      1
      0
      -1

      Hi, instead of using input[name=field] perhaps you can try using the Javascript API#getField(fieldId)

        CommentAdd your comment...