title: How to pass one element's value into another element's event handler in Javascript?
body: <p>I'm new to learning the DOM manipulations in JS and I've come across passing mostly, a single argument to the event handler's function, like <code>getSum(this)</code>. Let's say we have a simple addition function in the script tag, I've included those input elements inside the form, like this which is okay:</p>
  
  <pre><code>&lt;html&gt;
      &lt;body&gt;
          &lt;form id="operands" oninput="getSum(this)"&gt;
              &lt;input id="op1" type="number" name="op1" placeholder="op1"&gt;
              &lt;input id="op2" type="number" name="op2" placeholder="op2"&gt;
          &lt;/form&gt;
          &lt;p id="output"&gt;&lt;/p&gt;
          &lt;script&gt;
              function getSum(form_input){
                  form_input = document.getElementById("operands").elements;
                  document.getElementById("output").innerHTML = 
                      Number(form_input.namedItem("op1").value) + 
                      Number(form_input.namedItem("op2").value);
              }
          &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I'm trying to rewrite so that I can eliminate the use of form element, since there are only 2 child elements (input tags) within and pass both elements values in the second one like <code>getSum([], this)</code> like this:</p>
  
  <pre><code>&lt;html&gt;
      &lt;body&gt;
          &lt;input type="number" id="op1" name="op1" placeholder="op1"&gt;
          &lt;input type="number" id="op2" name="op2" placeholder="op2" oninput="getSum(*[op1's value]*, this)"&gt;
          &lt;p id="output"&gt;&lt;/p&gt;
          &lt;script&gt;
              function getSum(a, b){
                  document.getElementById("output").innerHTML = (Number(a.value) + Number(b.value));
              }
          &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>How can I pass the first input element's value to the <code>getSum(a, b)</code> function as argument a?</p>