title: How to send the contents of a text area to a function in Typescript / Javascript / Html
body: <p>Probably a very simple question, but I can't seem to find a way of sending a piece of data from a textarea to a javascript/typescript function.</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>  &lt;div  data-options="dxContent : { targetPlaceholder: 'content' } " &gt;
          &lt;p&gt; use this page to log errors&lt;/p&gt;
          &lt;p id="prevErrors" style="font-style:italic"&gt;PreviousErrors&lt;/p&gt;
          &lt;br /&gt;
          &lt;div id="curError" data-bind="dxTextArea: { }"&gt;&lt;/div&gt;
          &lt;br /&gt;
          &lt;div  data-bind="dxButton: { text: 'Save and return to main menu' }" onclick="    saveMyData(document.getElementById(curError).innerText)"&gt;&lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p><strong>Java/TypeScript</strong></p>
  
  <pre><code>&lt;script&gt;
  
  
          function saveMyData(curError) {
              //this will be where data is saved or emailed
              var today = new Date();
              var dd = today.getDate();
              var mm = today.getMonth() + 1; //January is 0!
              var yyyy = today.getFullYear();
              var h = today.getHours(); 
              var m = today.getMinutes(); 
              var s = today.getSeconds();
              if (dd &lt; 10) {
                  dd = '0' + dd
              }
              if (h &lt; 10) {
                  h = "0" + h;
              }
              if (s &lt; 10)
              {
                  s = "0"+s;
              }
              if (m &lt; 10) {
                  m = "0"+m;
              }
              if (mm &lt; 10) {
                  mm = '0' + mm
              }
  
              today = dd + '/' + mm + '/' + yyyy +" , "+h+":"+m+":"+s;
              prevErrors.innerText +=  "\n "+today+", "+curError;
          }
      &lt;/script&gt;
  </code></pre>
  
  <p>Having only recently found out that typescript and javascript are virtually identical anyway, I feel slightly embarrassed that starting up typescript has been such a battle - nothing like c#/vb/etc.</p>
  
  <p><strong>QUESTION</strong></p>
  
  <p>I have been trying to send data from this <code>dxtextArea</code> control to a function. as you can see, I have already tried using the <em>innerText</em>, however, this seems to send nothing into the function (getting the error:</p>
  
  <pre><code>'Uncaught TypeError: Cannot read property 'innerText' of null', line 1, file 'http://localhost:51828/index.html#'.
  </code></pre>
  
  <p>even when data is present in the textArea.</p>
  
  <p>Anyone come across this issue/know how to solve it/ or is it just my stupidity and naivety in knowledge of Java/typescript? </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I have been told to change my Method call from innerText to value (and add quotes around the ID), but this still hasn't solved the issue:</p>
  
  <pre><code>saveMyData(document.getElementById('curError').value)"
  </code></pre>
  
  <p><strong>EDIT 2</strong> My Full Script:</p>
  
  <pre><code>&lt;div data-options="dxView : { name: 'ErrorLogging', title: 'ErrorLogging' } " &gt;
      &lt;div  data-options="dxContent : { targetPlaceholder: 'content' } " &gt;
          &lt;p&gt;Use this page to log errors&lt;/p&gt;
          &lt;br /&gt;
          &lt;p style="font-style:italic"&gt;PreviousErrors&lt;/p&gt;
          &lt;p id="prevErrors" style="font-style:italic"&gt;&lt;/p&gt;
          &lt;br /&gt;
          &lt;div id="curError" data-bind="dxTextArea: { }" &gt;&lt;/div&gt;
          &lt;br /&gt;
          &lt;div  data-bind="dxButton: { text: 'Save and return to main menu' }" onclick="saveMyData(document.getElementById('curError').textContent)"&gt;&lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;script&gt;
  
      function saveMyData(elem) {
          //this will be where data is saved or emailed
  
  
          var today = new Date();
          var dd = today.getDate();
          var mm = today.getMonth() + 1; //January is 0!
          var yyyy = today.getFullYear();
          var h = today.getHours(); 
          var m = today.getMinutes(); 
          var s = today.getSeconds();
  
          //add a '0' in front of single digit values
          if (dd &lt; 10) {
              dd = '0' + dd
          }
          if (h &lt; 10) {
              h = "0" + h;
          }
          if (s &lt; 10)
          {
              s = "0"+s;
          }
          if (m &lt; 10) {
              m = "0"+m;
          }
          if (mm &lt; 10) {
              mm = '0' + mm
          }
  
          if (elem.textContent) {
              var curError = elem.textContent ?
                  elem.textContent :
                  elem.innerText;
          }
          alert(curError);
  
          today = dd + '/' + mm + '/' + yyyy +" , "+h+":"+m+":"+s; //created string containing todays' date and time
          prevErrors.innerText += "\n " + today + ", " + elem;
  
      }
  &lt;/script&gt;
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/mH3Iv.png" alt="Image of what it will look like on ios"></p>