title: using ajax to get data and update form field
body: <p>I added this code in the head:</p>
  
  <pre><code>&lt;script&gt;
  function cpf(pag) {
      request = createRequest();
      if(request == null) {
          alert("Unable to Create Request");
          return;
      }
      var nocache = new Date();
      var url = "https://pathto.com/cp/gettime.php?t="+pag;
      url = url + "&amp;stopIEcache="+ nocache;
      request.open("GET",url,true);
      request.onreadystatechange = showtpage;
      request.send(null);
  }
  
  function showtpage() {
      if(request.readyState == 4) {
          if(request.status == 200) {
              detailDiv = document.getElementByName("newtdf")[0];
              detailDiv.innerHTML = request.responseText;
          }
      }
  }
  
  function createRequest() {
      try {
          request = new XMLHttpRequest();
      } catch (tryMS) {
          try {
              request = new ActiveXObject("Msxml2.XMLHTTP");
          } catch (otherMS) {
              try {
                  request = new ActiveXObject("Microsoft.XMLHTTP");
              } catch (failed) {
                  request = null;
              }
          }
      }
      return request;
  }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Here is my HTML output by php:</p>
  
  <pre><code>&lt;input type="text" value="2014/10/10 05:08" id="datetimepicker" name="newtd" onBlur="cpf(document.getElementByName('newtd')[0].value);" /&gt;&lt;br /&gt;
  Epoch Timestamp Built: &lt;input type="text" name="newtdf" size="10" value=""&gt;
  </code></pre>
  
  <p>So I have the first field that is selectable by a datetimepicker, when they leave the field (onblur), it should run the cpf function I created on the script, and pass the value of the field to it.</p>
  
  <p>But it is not working.</p>
  
  <p>I ran it and with the debugger, it says this:</p>
  
  <pre><code>Uncaught TypeError: undefined is not a function
  </code></pre>
  
  <p>can you help me fix it please?</p>