title: Uncaught TypeError: Cannot read property 'toString' of undefined
body: <p>Why is my code not working?
  Chrome gives me the following error: <code>Uncaught TypeError: Cannot read property 'toString' of undefined</code>.</p>
  
  <p>It works with 1,2,3,4,6,7,8,9 but does not work with 5,10,15,...</p>
  
  <p>Please help me out.</p>
  
  <p>Here is my javascript code:</p>
  
  <pre><code>&lt;code&gt;&lt;script&gt;
  function mmCal(val) {
      var a, b, c, d, e, f, g, h, i;
      a = val * 25.4;
      b = a.toString().split(".")[0];
      c = a.toString().split(".")[1];
      d = c.toString().substr(0, 1);
      e = +b + +1;
      f = b;
  
      if (d&gt;5) {
          document.getElementById("txtt").value = e;
      } else {
          document.getElementById("txtt").value = f;
      }
  }
  &lt;/script&gt;&lt;/code&gt;
  </code></pre>
  
  <p>Here is my html:</p>
  
  <pre><code>&lt;code&gt;&lt;input type="text" id="txt" value="" onchange="mmCal(this.value)"&gt;&lt;/code&gt;
  &lt;code&gt;&lt;input type="text" id="txtt" value=""&gt;&lt;/code&gt;
  </code></pre>