title: show result which is created through JavaScript in input field
body: <p>I have a form in which a date/time picker is working fine.</p>
  
  <p>I created JavaScript to calculate the two fields' date difference and show in a third field - named <strong>Course Duration</strong>.</p>
  
  <p>Somehow I am not able to display the results in the "Course Duration" input Field.</p>
  
  <p>Code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function GetDays() {
    var dropdt = new Date(document.getElementById("course_end_date").value);
    var pickdt = new Date(document.getElementById("admission_date").value);
    return parseInt((dropdt - pickdt) / (24 * 3600 * 1000));
  }
  
  function cal() {
    if (document.getElementById("course_end_date")) {
      document.getElementById("course_duration").value = GetDays();
    }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;input id="admission_date" name="admission_date" placeholder="" type="text" class="form-control" value="" /&gt;
  &lt;input id="course_end_date" name="course_end_date" placeholder="" type="text" class="form-control" value="" /&gt;
  &lt;input id="course_duration" name="course_duration" placeholder="" type="text" class="form-control" value="" /&gt;</code></pre>
  </div>
  </div>
  </p>