title: date time with document.getElementById not working
body: <p>beneath you see a piece of custom code for Zendesk. Everything works fine, till I want to implement a date/time snippet.</p>
  
  <p><strong>Normally the script works like this:</strong></p>
  
  <p>1 - there is a button which says "Print Ticket".</p>
  
  <p>2 - The button has a onclick event to open a printer friendly page ready for printing.</p>
  
  <p>After implementing the date/time code (what I didn't do well I believe) I only get the printable version of the ticket, but the time isn't displayed. (nothing happended really)</p>
  
  <p>The only thing what happends is that the date and time are shown without the rest of the printable form.</p>
  
  <p>I think the placemanet of the javascript is not in th right place, it needs to be in the head section which is generated also by javascript</p>
  
  <p>Can anyone please help me with this? or point me in a vorm of example what to do?</p>
  
  <pre><code>&lt;style&gt;
  input.createtable {
      display:none;
  }
  &lt;/style&gt;
  &lt;script language="JavaScript"&gt;
  
  // Get today's current date.
  var now = new Date();
  
  // Array list of days.
  var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
  
  // Array list of months.
  var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
  
  // Calculate the number of the current day in the week.
  var date = ((now.getDate()&lt;10) ? "0" : "")+ now.getDate();
  
  // Calculate four digit year.
  function fourdigits(number) {
      return (number &lt; 1000) ? number + 1900 : number;
                                  }
  
  // Join it all together
  today =  days[now.getDay()] + ", " +
           months[now.getMonth()] + " " +
           date + ", " +
           (fourdigits(now.getYear())) ;
  
  // Print out the data.
  // document.write(today);
  
  // Begin altered code
  
  document.getElementById("date").innerHTML = today;
  
  // End altered code
  
  //  End --&gt;
  &lt;/script&gt;
  &lt;script language="JavaScript"&gt;
  &lt;!--
  writeConsole = function(content) {
   top.consoleRef=window.open('','myconsole',
    'width=800,height=800'
     +',menubar=0'
     +',toolbar=0'
     +',status=0'
     +',scrollbars=1'
     +',resizable=1')
  // top.consoleRef.document.open("text/html","replace");
   top.consoleRef.document.writeln(
    '&lt;html&gt;&lt;head&gt;&lt;title&gt;Signature Page&lt;/title&gt;&lt;/head&gt;'
   +'&lt;style&gt;th {color: #FFFFFF;border-bottom: 1px solid #000000;background-color:#CCCCCC;}tr {color: #000000;border-bottom: 1px solid #cccccc;}td.small {color: #000000; font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif;}td.large {color: #000000; font-size: 120%; font-family: Arial, Helvetica, sans-serif;font-weight: bold; text-align:center;}&lt;/style&gt;'
   +'&lt;link href="http://asset3.zendesk.com/stylesheets_old/zd_print.css?1270161524" media="print" rel="stylesheet" type="text/css" /&gt;'
   +'&lt;body onLoad="self.focus()" style="background: white; font-size: 11px; font-family: Verdana, Arial, Helvetica, sans-serif"&gt;'
   +'&lt;center&gt;&lt;A HREF="javascript:window.print()"&gt;Print Werkorder&lt;/A&gt;&lt;/center&gt;'
   +'&lt;table width="100%"&gt;&lt;tr&gt;&lt;td align="left" valign="middle"&gt;'
   +'&lt;/td&gt;&lt;br /&gt;'
   +'www.domain.nl&lt;br /&gt;'
   +'Tel: 058-111111111&lt;br /&gt;'
   +'E-mail info@domain.nl'
   +'&lt;/tr&gt;&lt;/table&gt;'
   +content
   +'&lt;/body&gt;&lt;/html&gt;'
   )
   top.consoleRef.document.close()
  }
  //--&gt;
  &lt;/script&gt;
  
  
  &lt;form&gt;
    &lt;input class="createtable" name=userInput type=textarea size="1" value="&lt;table width=100% height=825 border=0 cellpadding=6 cellspacing=4&gt;
    &lt;tr&gt;
      &lt;th colspan=6&gt;&lt;h1&gt;WERKORDER NR#: {{ticket.id}}&lt;/h1&gt;&lt;/th&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td colspan=6&gt;&lt;hr width=100% noshade=noshade /&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td width=13% valign=top&gt;&lt;strong&gt;Klantinformatie:&lt;/strong&gt;&lt;/td&gt;
      &lt;td width=87% align=left valign=top&gt;&lt;p&gt;&lt;strong&gt;Datum:    &lt;div id=date&gt;&lt;/div&gt;  
  
      &lt;br /&gt;
        Naam&lt;/strong&gt;: {{ticket.requester.name}}&lt;br /&gt;
        &lt;strong&gt;Bedrijf:&lt;/strong&gt; {{ticket.organization.name}}&lt;br /&gt;
        &lt;strong&gt;Telefoonnummer:&lt;/strong&gt; {{ticket.ticket_field_484140}}&lt;br /&gt;
      &lt;strong&gt;E-mail:&lt;/strong&gt; {{ticket.requester.email}}&lt;/p&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td valign=top&gt;&lt;strong&gt;In ontvangst genomen:&lt;/strong&gt;&lt;/td&gt;
      &lt;td align=left valign=top&gt;&lt;strong&gt;Merk &amp;amp; Model:&lt;/strong&gt; {{ticket.ticket_field_483591}}&lt;br /&gt;
        &lt;strong&gt;Hardware Type:&lt;/strong&gt; {{ticket.ticket_field_484179}}&lt;br /&gt;
        &lt;strong&gt;Uitbesteed:&lt;/strong&gt; {{ticket.ticket_field_483608}}&lt;br /&gt;
      &lt;strong&gt;Prioriteit:&lt;/strong&gt; {{ticket.priority}}&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td colspan=6&gt;&lt;hr width=100% noshade=noshade /&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td valign=top&gt;&lt;strong&gt;Overeengekomen:&lt;/strong&gt;&lt;/td&gt;
      &lt;td colspan=5 rowspan=2 valign=top&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td colspan=6&gt;&lt;hr width=100% noshade=noshade /&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td valign=top&gt;&lt;strong&gt;Handtekening voor akkoord:&lt;/strong&gt;&lt;/td&gt;
      &lt;td colspan=5&gt;&lt;table width=100% border=0 cellspacing=7 cellpadding=7&gt;
        &lt;tr&gt;
          &lt;td width=33%&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td width=33%&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td width=31%&gt;&amp;nbsp;&lt;/td&gt;
          &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td width=33%&gt;&lt;hr noshade=noshade /&gt;&lt;/td&gt;
          &lt;td width=33%&gt;&lt;hr /&gt;&lt;/td&gt;
          &lt;td&gt;&lt;hr /&gt;&lt;/td&gt;
          &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td width=33%&gt; {{ticket.requester.name}} &lt;/td&gt;
          &lt;td width=33%&gt;Datum:&lt;/td&gt;
          &lt;td&gt;Plaats:&lt;/td&gt;
          &lt;/tr&gt;
        &lt;/table&gt;      &lt;p&gt;&lt;br /&gt;
      &lt;/p&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;"&gt;
    &lt;input type=button value="Print Werkorder"
  onClick="writeConsole(this.form.userInput.value)"
  &gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Edit question</strong></p>
  
  <p>This is what I have now, the form appears again, but without a date, why is this?</p>
  
  <p>I'll post in short the code again:</p>
  
  <p><strong>the altered javascript:</strong></p>
  
  <pre><code>&lt;script language="JavaScript"&gt;
  
  // Get today's current date.
  var now = new Date();
  
  // Array list of days.
  var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
  
  // Array list of months.
  var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
  
  // Calculate the number of the current day in the week.
  var date = ((now.getDate()&lt;10) ? "0" : "")+ now.getDate();
  
  // Calculate four digit year.
  function fourdigits(number) {
      return (number &lt; 1000) ? number + 1900 : number;
                                  }
  
  // Join it all together
  today =  days[now.getDay()] + ", " +
           months[now.getMonth()] + " " +
           date + ", " +
           (fourdigits(now.getYear())) ;
  
  // Print out the data.
  // document.write(today);
  
  // Begin altered code
  
  document.getElementById("date").innerHTML = today;
  
  // End altered code
  
  //  End --&gt;
  &lt;/script&gt;
  </code></pre>