"Uncaught TypeError: Cannot read property 'Name' of undefined" when triggered a function
<p><strong>EDIT: I found that the code is working fine and nothing is wrong. It's myself that was blurred. Sorry for not being cautious.</strong></p>

<p>I have a HTML file with a form containing a textbox with ID #StuIDtxt.</p>

<p>Also there is a few JavaScript, and here is a code in my file. The function getResult() would be triggered when the form is submitted.</p>

<pre><code>function getResult(){
  var StuID = document.getElementById('StuIDtxt').value;
  document.getElementById('name').innerHTML = result[StuID].Name;
  return false;
}
</code></pre>

<p>There is also a variable name 'result' storing array parsed from JSON.</p>

<p>When I fill the textbox with '10001' and submit the form, JavaScript console said </p>

<pre><code>Uncaught TypeError: Cannot read property 'Name' of undefined
</code></pre>

<p>However typing</p>

<pre><code>document.getElementById('name').innerHTML = result['10001'].Name;
</code></pre>

<p>in console result in successful execution as expected.</p>

<p>Did I do anything wrong in the function?</p>

<p>Live web here: <a href="https://srakrn.com/satitnpru/announce" rel="nofollow">https://srakrn.com/satitnpru/announce</a></p>