title: Uncaught TypeError: Cannot set property 'value' of undefined - JS
body: <p><a href="https://i.stack.imgur.com/6rr4m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6rr4m.png" alt="enter image description here"></a></p>
  
  <p>Hello guys, Can someone help me how to fix this error? Im trying to figure it out for 3 hours but still can't fix. It's working in the first try or first fire of the event, but if event fires again it's not working anymore. </p>
  
  <p>HERE'S THE SCRIPT.</p>
  
  <pre><code>&lt;script type="text/javascript" language="Javascript"&gt;
    var sum=0;
      function OnChange(value){
  
      price =   document.getElementById('select1').value;      
      quantity = document.getElementById('select2').value;  
          sum = price * quantity;
  
      document.frmOne.txtDisplay.value = sum;
      }
  &lt;/script&gt;
  &lt;SCRIPT language=Javascript&gt;
          &lt;!--
          function isNumberKey(evt)
          {
           var charCode = (evt.which) ? evt.which : event.keyCode
           if (charCode &gt; 31 &amp;&amp; (charCode &lt; 48 || charCode &gt; 57))
            return false;
  
           return true;
          }
          //--&gt;
      &lt;/SCRIPT&gt;
  </code></pre>
  
  <p>HERE'S THE FORM</p>
  
  <pre><code>&lt;form NAME = "frmOne" action="initiateorder.php" method="post" enctype="multipart/form-data"&gt;
    &lt;input type="hidden" name="transnum" value="&lt;?php echo $_GET['trnasnum'] ?&gt;" /&gt;
    &lt;INPUT TYPE = "Text" name = "select1" size = "35" id="select1" value ="&lt;?php echo $price ?&gt;" style="display:none;"&gt;
    &lt;INPUT TYPE = "Text" name = "pname" size = "35" value ="&lt;?php echo $name ?&gt;" style="display:none;"&gt;
      &lt;br&gt;
      &lt;span style="font-size:11px; font-family:Arial, Helvetica, sans-serif; text-align:left; line-height:17px;color:#000000;"&gt;Quantity : &lt;/span&gt;
    &lt;input type="text" name="select2" id="select2" onkeyup="OnChange(this.value)" onKeyPress="return isNumberKey(event)" style="width:60px;" /&gt; 
  
     &lt;span style="color:#B80000; font-size:16px; font-weight:bold; font-family:Arial, Helvetica, sans-serif;"&gt;=&lt;/span&gt; 
      &lt;INPUT TYPE = "Text" name = "txtDisplay" size = "35" value ="&lt;?php echo $price ?&gt;" style="border:#999999 solid 1px; background-color:#FFF; width:100px; height:20px;" readonly&gt;
  &lt;/form&gt;
  </code></pre>