title: Uncaught Type Error: Cannont set Property 'valueAsDate' of null
body: <p>I am getting this weird error that I attempting to debug. I have an input field that has the current time pre-displayed as the value. When I run the page I get the Uncaught Type error referring to the JavaScript file line number 8 (<code>document.getElemntByID(&quot;theTime&quot;).valueAsDate=b;</code>)</p>
  <p>Is it trying to say <code>ValueAsDate</code> is not defined? What do I put in place of it? Any help is most appreciated.</p>
  <p>html</p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
     &lt;head&gt;
        &lt;meta charset=&quot;UTF-8&quot; content=&quot;HTML,CSS,XML,JavaScript&quot;&gt;
         &lt;script src=&quot;Scripts/jquery.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
         &lt;script src=&quot;Scripts/Global.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
      
            
        &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;Styles/Design.css&quot;&gt;
     &lt;/head&gt;
           &lt;body&gt;         
                 &lt;form action=&quot;&quot; method=&quot;post&quot;&gt;
                    &lt;fieldset&gt;
                       &lt;table border=&quot;0px&quot; &gt;
                          &lt;tr&gt;
                             &lt;td colspan = &quot;2&quot; id=&quot;formHeader&quot;&gt;
                                Select Date and Time
                             &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                             &lt;td class=&quot;spaceUnder&quot;  id=&quot;formBody&quot;&gt;Date: &amp;nbsp;&amp;nbsp;&lt;input type=&quot;date&quot; id=&quot;theDate&quot;&gt;&lt;/td&gt;
                             &lt;td  align=&quot;center&quot; class=&quot;spaceUnder&quot;  id=&quot;formBody&quot;&gt;Time: &amp;nbsp;&lt;input type=&quot;time&quot; id=&quot;theTime&quot; &gt;&lt;/td&gt;
                          &lt;/tr&gt;                     
                       &lt;/table&gt;
                    &lt;/fieldset&gt;
                 &lt;/form&gt; 
           &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>JavaScript</p>
  <pre><code>$(document).ready(function() {
      myTimer();
  });
  function myTimer() {
      var a = new Date();
      var b = new Date(a.getFullYear(), a.getMonth(), a.getDate(), a.getHours() - 8, a.getMinutes());
      //$(&quot;#theTime&quot;)[0].valueAsDate = b;
      document.getElementById(&quot;theTime&quot;).valueAsDate =b;
  }
  </code></pre>