title: Set value to a hidden input
body: <p>As you can see I am a newbie on JavaScript and I am working on a form that needs to send the today's date value when a user hits submit to know when the information was last updated.</p>
  
  <p>I currently have the following code, but doesn't seem to update the date on the field. Could you please help me understand why?</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>&lt;script type="text/javascript"&gt;
  
    var datetoday = new Date();
    var months = new makeArray('Jan','Feb','Mar','Apr','May','June','July','Aug','Sept','Oct','Nov','Dec');
    var day = datetoday.getDate();
    var month = datetoday.getMonth() + 1;
    var yyyy = datetoday.getFullYear();
    var my_date = day+"-"+months[month]+"-"+yyyy;
  
    document.getElementById("DATE_TODAY").value = my_date;
  &lt;/script&gt;</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form method="POST"&gt;
    * First Name:
    &lt;input name="FNAME" type="text" /&gt;
    &lt;br&gt;
    * Last Name:
    &lt;input name="LNAME" type="text" /&gt;
    &lt;br&gt;
    * Street Address:
    &lt;input name="ADDRESS" type="text" /&gt;
    &lt;input type="hidden" name="DATE_TODAY" id="DATE_TODAY" /&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>