title: Date/Time Picker inside an HTML table (Javascript inside <table> tags) in MVC
body: <p>I have a table in my view model in my MVC project, which contains multiple entries of a data type. I would like to be able to edit all those items at once. </p>
  
  <p>One of the field is a date/time type, and I would like to implement a date/time picker for the field, but that would involve in a javascript inside my table tags due to loop constraints. Is there any way to overcome this?</p>
  
  <p>Here is my view model:</p>
  
  <pre><code>    @foreach (var item in Model)
      {
          &lt;tr&gt;
              &lt;td&gt;
                  @Html.EditorFor(modelItem =&gt; item.A_Date, new { htmlAttributes = new { @Value = item.A_Date, @class = "form-control" } })
              &lt;/td&gt;
          &lt;/tr&gt;
      }
  
  &lt;/table&gt;
  
      &lt;script type="text/javascript"&gt;
          $(function () {
              $('#A_Date').datetimepicker({
                  calendarWeeks: true,
                  //dateFormat: 'YYYY MM dd',
                  //defaultDate: '',
                  format: 'YYYY-MM-DD',
                  showClose: true,
                  showClear: true,
                  toolbarPlacement: 'top',
              });
  
              $('#A_Date').datetimepicker({
                  //defaultDate: '',
                  format: 'LT',
                  showClose: true,
                  showClear: true,
                  toolbarPlacement: 'top',
                  stepping: 15,
              });
          });
      &lt;/script&gt;
  </code></pre>
  
  <p>Please advise. Thanks!</p>