title: Calculate quantity where textbox is a certain value
body: <p><strong>Edit</strong></p>
  
  <p>So many good answers and all of them work! Thanks a lot guys :) I wish I could mark all of them as solved!</p>
  
  <p><strong>----</strong></p>
  
  <p>Good day</p>
  
  <p>Let's say I have these 2 text inputs:</p>
  
  <pre><code>&lt;input type="text" id="plt_quantity_sum"/&gt; &lt;!-- this should calculate the "#quantity" where each "#uom_value" is "PLT" --&gt;
  &lt;input type="text" id="crt_quantity_sum"/&gt;&lt;!-- this should calculate the "#quantity" where each "#uom_value" is "CRT" --&gt;
  </code></pre>
  
  <p>Let's assume the following scenario:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;table&gt;
      &lt;tbody&gt;
      &lt;tr&gt;
      &lt;th&gt;Item Name&lt;/th&gt;
      &lt;th id="uom_value"&gt;UOM&lt;/th&gt;
      &lt;th id="qty"&gt;Quantity&lt;/th&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;Item 1&lt;/td&gt;
      &lt;td id="uom_value"&gt;PLT&lt;/td&gt;
      &lt;td id="qty"&gt;5&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;Item 2&lt;/td&gt;
      &lt;td class="uom_value"&gt;PLT&lt;/td&gt;
      &lt;td id="qty"&gt;3&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;Item 3&lt;/td&gt;
      &lt;td id="uom_value"&gt;CRT&lt;/td&gt;
      &lt;td id="qty"&gt;2&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;tr&gt;
      &lt;td&gt;Item 4&lt;/td&gt;
      &lt;td id="uom_value"&gt;CRT&lt;/td&gt;
      &lt;td id="qty"&gt;3&lt;/td&gt;
      &lt;/tr&gt;
  
      &lt;/tbody&gt;
      &lt;/table&gt;
      
      &lt;input type="text" id="plt_quantity_sum" /&gt;
      &lt;input type="text" id="crt_quantity_sum" /&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>What needs to happen:</strong></p>
  
  <p>When the document loads, or via a button click; the quantity of "#plt_quantity_sum" and "#crt_quantity_sum" should be calculated based on their respective quantities and "UOM" values.</p>
  
  <p>Some Javascript I had in mind which should clarify what exactly needs to happen:</p>
  
  <pre><code>$(document).ready(function(){
  if (document.getElementById("#uom_value").value == "PLT"){ 
  
  document.getElementById("#plt_quantity_sum").value == (sum of #qty); 
  
  }
  
  else if (document.getElementById("#uom_value").value == "CRT"){
  
  document.getElementById("#crt_quantity_sum").value == (sum of #qty); 
  
  }
  
  });
  </code></pre>
  
  <p>Thanks for reading and I would greatly appreciate any help.</p>