title: How to add date value in dynamically created date field using Jquery
body: <p>I need one help. I have one <code>json array</code> and I need to add some date value present inside that <code>JSON array</code> in dynamically created date field using Jquery. I am explaining my code below.</p>
  
  <pre><code>$depdate=[  
     {  
        "sett_id":"270",
        "sett_name":"Car",
        "sett_type":"vtypes",
        "id":"6",
        "dep_dates":"31-10-2018,07-11-2018,14-11-2018,21-11-2018,28-11-2018",
        "vehicle_type":"270"
     },
     {  
        "sett_id":"271",
        "sett_name":"Bus",
        "sett_type":"vtypes",
        "id":"7",
        "dep_dates":"01-11-2018,08-11-2018,22-11-2018,15-11-2018,29-11-2018,06-12-2018",
        "vehicle_type":"271"
     }] 
  </code></pre>
  
  <p>This is my <code>JSON array</code> value which has key <code>dep_dates</code> and it contains all dates with comma separate. I am explaining the code below.</p>
  
  <pre><code>&lt;?php foreach ($depdate as $key =&gt; $value) { 
                  $dep_date=explode(",",$value['dep_dates']);
                  //print_r($dep_date);exit;
                ?&gt;
                &lt;tr&gt;
                  &lt;td&gt;&lt;?php echo $key+1; ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $value['sett_name']; ?&gt;&lt;/td&gt;
                  &lt;td&gt;&lt;div class="input_fields_wrap&lt;?php echo $key+1; ?&gt; form-horizontal"&gt;&lt;div style="margin-bottom: 5px;"&gt;&lt;input type="text" name="ddate_&lt;?php echo $value['sett_id']; ?&gt;[]" value="" class="depdate&lt;?php echo $key+1; ?&gt; form-control"  style="width:280px;max-width:280px;display:inline-block"&gt;&lt;button type="button" class="add_field_button&lt;?php echo $key+1; ?&gt; btn btn-primary" style="margin-left: 2px; margin-top: -5px;min-height: 30px;"&gt;&lt;i class="fa fa-plus"&gt;&lt;/i&gt;&lt;/button&gt;&lt;/div&gt;&lt;/div&gt;&lt;/td&gt;
                  &lt;input type="hidden" name="vid_&lt;?php echo $value['sett_id']; ?&gt;_id" value="&lt;?php echo $value['sett_id']; ?&gt;" &gt;
                &lt;/tr&gt;
                &lt;script&gt;
                  $(function(){
                    var addButton = $('.add_field_button&lt;?php echo $key+1; ?&gt;');
                    var wrapper = $('.input_fields_wrap&lt;?php echo $key+1; ?&gt;');
                    var nowTemp = new Date();
                    var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
                    $(addButton).click(function(){
                      $(wrapper).append('&lt;div style="margin-bottom: 5px;"&gt;&lt;input type="text" name="ddate_&lt;?php echo $value['sett_id']; ?&gt;[]" value="" class="depdate&lt;?php echo $key+1; ?&gt; form-control"  style="width:280px;max-width:280px;display:inline-block"/&gt;&lt;button type="button" class="remove_field&lt;?php echo $key+1; ?&gt; btn btn-danger" style="margin-left: 2px; margin-top: -5px;min-height: 30px;"&gt;&lt;i class="fa fa-minus"&gt;&lt;/i&gt;&lt;/button&gt;&lt;/div&gt;'); //add input box
                      $('.depdate&lt;?php echo $key+1; ?&gt;').datepicker({
                        format: 'dd-mm-yyyy',
                        onRender: function(date) { 
                          return date.valueOf() &lt; now.valueOf() ? 'disabled' : ''; 
                        } 
                      });
                    })
                    $(wrapper).on('click', '.remove_field&lt;?php echo $key+1; ?&gt;', function(e){
                      e.preventDefault();
                      $(this).parent('div').remove();
                    })
                    $('.depdate&lt;?php echo $key+1; ?&gt;').datepicker({
                      format: 'dd-mm-yyyy',
                      onRender: function(date) { 
                        return date.valueOf() &lt; now.valueOf() ? 'disabled' : ''; 
                      }
                    });
                  })
                &lt;/script&gt;
                &lt;?php } ?&gt;
  </code></pre>
  
  <p>Here I have one date field with <code>+</code> button and when user will click on it new field is creating. Here My requirement is if <code>dep_dates</code> has any value it will converted into array and the date field will created dynamically as per no of date value and those value will append into the field. Actually this is the <code>update</code> feature. Please help me to do this.</p>